Commit e28a4185 authored by Stephen McGruer's avatar Stephen McGruer Committed by Commit Bot

Roll new WPT js code.

This rolls up to sha e7928355119c150c784d2d32da699717f61ed346

This brings in the async_test return-value change, as well as some
changes to testdriver.

Bug: None
Change-Id: I49022e105c8ea6070eeee7031b3002eefbdb0d3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432628Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811215}
parent 1bb35d1e
......@@ -18,15 +18,14 @@ var animation = div.animate(null, 100 * MS_PER_SEC);
var startTimeBefore = animation.startTime;
animation.currentTime = 7 * MS_PER_SEC; // ms
async_test(t => {
return animation.ready.then(t.step_func_done(() => {
animation.finish();
assert_equals(animation.playState, "finished");
promise_test(async t => {
await animation.ready;
animation.finish();
assert_equals(animation.playState, "finished");
assert_not_equals(animation.startTime, null)
animation.playbackRate = 0.5;
assert_not_equals(animation.startTime, null)
animation.playbackRate = 0.5;
assert_false(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
}))
assert_false(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
}, 'Check to ensure that we UseCount when you cause a compensatory seek by setting playbackRate when finished');
</script>
......@@ -18,16 +18,15 @@ var animation = div.animate(null, 100 * MS_PER_SEC);
var startTimeBefore = animation.startTime;
animation.currentTime = 7 * MS_PER_SEC; // ms
async_test(t => {
return animation.ready.then(t.step_func_done(() => {
var current_time = animation.currentTime;
animation.pause();
animation.currentTime = current_time;
assert_equals(animation.playState, "paused");
promise_test(async t => {
await animation.ready;
var current_time = animation.currentTime;
animation.pause();
animation.currentTime = current_time;
assert_equals(animation.playState, "paused");
animation.playbackRate = 0.5;
animation.playbackRate = 0.5;
assert_false(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
}))
assert_false(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
}, 'Check to ensure that we UseCount when you cause a compensatory seek by setting playbackRate when paused');
</script>
......@@ -18,21 +18,20 @@ var animation = div.animate(null, 100 * MS_PER_SEC);
var startTimeBefore = animation.startTime;
animation.currentTime = 7 * MS_PER_SEC; // ms
async_test(t => {
return animation.ready.then(t.step_func_done(() => {
promise_test(async t => {
await animation.ready;
assert_equals(animation.playState, "running");
assert_not_equals(startTimeBefore, animation.startTime);
assert_equals(animation.playState, "running");
assert_not_equals(startTimeBefore, animation.startTime);
assert_false(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
assert_false(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
animation.playbackRate = 1.0;
animation.playbackRate = 1.0;
assert_false(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
assert_false(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
animation.playbackRate = 0.5;
animation.playbackRate = 0.5;
assert_true(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
}))
assert_true(internals.isUseCounted(document, AnimationSetPlaybackRateCompensatorySeek));
}, 'Check to ensure that we UseCount when you cause a compensatory seek by setting playbackRate when playing');
</script>
......@@ -25,16 +25,18 @@ frame.contentDocument.write(`
\<\/script>
`);
frame.contentDocument.close();
async_test(t => requestAnimationFrame(() => {
frame.contentDocument.querySelector('#focus').focus();
async_test(t => {
requestAnimationFrame(() => {
// Update style.
frame.contentWindow.getComputedStyle(
frame.contentDocument.querySelector('#focus')).backgroundColor;
// Invalidate style with an animation style change.
frame.contentWindow.anim.currentTime += 1000;
frame.contentWindow.internals.setFocused(false);
t.done();
frame.contentDocument.querySelector('#focus').focus();
requestAnimationFrame(() => {
// Update style.
frame.contentWindow.getComputedStyle(
frame.contentDocument.querySelector('#focus')).backgroundColor;
// Invalidate style with an animation style change.
frame.contentWindow.anim.currentTime += 1000;
frame.contentWindow.internals.setFocused(false);
t.done();
});
});
}))
});
</script>
......@@ -4,7 +4,7 @@
<script src="../resources/testharnessreport.js"></script>
<script async id="script" src="resources/script-slow1.pl"></script>
<script>
async_test(t => t.step_timeout(() => t.done(), 3000),
async_test(t => { t.step_timeout(() => t.done(), 3000); },
"Moving a script to a createDocument()ed Document " +
"during fetch shouldn't crash");
const doc = document.implementation.createDocument("", null);
......
This is a testharness.js-based test.
FAIL drag-selected-image-to-contenteditable resources/testharness.js:1977:25)
FAIL drag-selected-image-to-contenteditable resources/testharness.js:2001:25)
expected <style>div, img { width: 200px; height: 100px; }</style><div contenteditable id="target">^<img id="image">|</div><img id="image">,
but got <style>div, img { width: 200px; height: 100px; }</style><div contenteditable id="target"></div>^<img id="image">|,
sameupto <style>div, img { width: 200px; height: 100px; }</style><div contenteditable id="target">
......
......@@ -9,6 +9,7 @@
function Actions(defaultTickDuration=16) {
this.sourceTypes = new Map([["key", KeySource],
["pointer", PointerSource],
["wheel", WheelSource],
["none", GeneralSource]]);
this.sources = new Map();
this.sourceOrder = [];
......@@ -73,7 +74,7 @@
* If no name is passed, a new source with the given type is
* created.
*
* @param {String} type - Source type ('none', 'key', or 'pointer')
* @param {String} type - Source type ('none', 'key', 'pointer', or 'wheel')
* @param {String?} name - Name of the source
* @returns {Source} Source object for that source.
*/
......@@ -154,6 +155,32 @@
return this;
},
/**
* Add a new wheel input source with the given name
*
* @param {String} type - Name of the wheel source
* @param {Bool} set - Set source as the default wheel source
* @returns {Actions}
*/
addWheel: function(name, set=true) {
this.createSource("wheel", name);
if (set) {
this.setWheel(name);
}
return this;
},
/**
* Set the current default wheel source
*
* @param {String} name - Name of the wheel source
* @returns {Actions}
*/
setWheel: function(name) {
this.setSource("wheel", name);
return this;
},
createSource: function(type, name, parameters={}) {
if (!this.sources.has(type)) {
throw new Error(`${type} is not a valid action type`);
......@@ -196,8 +223,9 @@
*
* @param {Number?} duration - Minimum length of the tick in ms.
* @param {String} sourceType - source type
* @param {String?} sourceName - Named key or pointer source to use or null for the default
* key or pointer source
* @param {String?} sourceName - Named key, pointer or wheel source to use
* or null for the default key, pointer or
* wheel source
* @returns {Actions}
*/
pause: function(duration=0, sourceType="none", {sourceName=null}={}) {
......@@ -280,6 +308,27 @@
source.pointerMove(this, x, y, duration, origin);
return this;
},
/**
* Create a scroll event for the current default wheel source
*
* @param {Number} x - mouse cursor x coordinate
* @param {Number} y - mouse cursor y coordinate
* @param {Number} deltaX - scroll delta value along the x-axis in pixels
* @param {Number} deltaY - scroll delta value along the y-axis in pixels
* @param {String|Element} origin - Origin of the coordinate system.
* Either "viewport" or an Element
* @param {Number?} duration - Time in ms for the scroll
* @param {String?} sourceName - Named wheel source to use or null for the
* default wheel source
* @returns {Actions}
*/
scroll: function(x, y, deltaX, deltaY,
{origin="viewport", duration, sourceName=null}={}) {
let source = this.getSource("wheel", sourceName);
source.scroll(this, x, y, deltaX, deltaY, duration, origin);
return this;
},
};
function GeneralSource() {
......@@ -417,5 +466,46 @@
},
};
function WheelSource() {
this.actions = new Map();
}
WheelSource.prototype = {
serialize: function(tickCount) {
if (!this.actions.size) {
return undefined;
}
let actions = [];
let data = {"type": "wheel", "actions": actions};
for (let i=0; i<tickCount; i++) {
if (this.actions.has(i)) {
actions.push(this.actions.get(i));
} else {
actions.push({"type": "pause"});
}
}
return data;
},
scroll: function(actions, x, y, deltaX, deltaY, duration, origin) {
let tick = actions.tickIdx;
if (this.actions.has(tick)) {
tick = actions.addTick().tickIdx;
}
this.actions.set(tick, {type: "scroll", x, y, deltaX, deltaY, origin});
if (duration) {
this.actions.get(tick).duration = duration;
}
},
addPause: function(actions, duration) {
let tick = actions.tickIdx;
if (this.actions.has(tick)) {
tick = actions.addTick().tickIdx;
}
this.actions.set(tick, {type: "pause", duration: duration});
},
};
test_driver.Actions = Actions;
})();
......@@ -15,7 +15,8 @@
}
function getPointerInteractablePaintTree(element) {
if (!window.document.contains(element)) {
let elementDocument = element.ownerDocument;
if (!elementDocument.contains(element)) {
return [];
}
......@@ -27,10 +28,10 @@
var centerPoint = getInViewCenterPoint(rectangles[0]);
if ("elementsFromPoint" in document) {
return document.elementsFromPoint(centerPoint[0], centerPoint[1]);
} else if ("msElementsFromPoint" in document) {
var rv = document.msElementsFromPoint(centerPoint[0], centerPoint[1]);
if ("elementsFromPoint" in elementDocument) {
return elementDocument.elementsFromPoint(centerPoint[0], centerPoint[1]);
} else if ("msElementsFromPoint" in elementDocument) {
var rv = elementDocument.msElementsFromPoint(centerPoint[0], centerPoint[1]);
return Array.prototype.slice.call(rv ? rv : []);
} else {
throw new Error("document.elementsFromPoint unsupported");
......@@ -95,14 +96,6 @@
* the cases the WebDriver command errors
*/
click: function(element) {
if (window.top !== window) {
return Promise.reject(new Error("can only click in top-level window"));
}
if (!window.document.contains(element)) {
return Promise.reject(new Error("element in different document or shadow tree"));
}
if (!inView(element)) {
element.scrollIntoView({behavior: "instant",
block: "end",
......@@ -135,14 +128,6 @@
* the cases the WebDriver command errors
*/
send_keys: function(element, keys) {
if (window.top !== window) {
return Promise.reject(new Error("can only send keys in top-level window"));
}
if (!window.document.contains(element)) {
return Promise.reject(new Error("element in different document or shadow tree"));
}
if (!inView(element)) {
element.scrollIntoView({behavior: "instant",
block: "end",
......@@ -176,7 +161,7 @@
/**
* Send a sequence of actions
*
* This function sends a sequence of actions to the top level window
* This function sends a sequence of actions
* to perform. It is modeled after the behaviour of {@link
* https://w3c.github.io/webdriver/#actions|WebDriver Actions Command}
*
......
......@@ -535,12 +535,13 @@ policies and contribution forms [3].
var value = test_obj.step(func, test_obj, test_obj);
if (value !== undefined) {
var msg = "Test named \"" + test_name +
"\" inappropriately returned a value";
var msg = 'Test named "' + test_name +
'" passed a function to `test` that returned a value.';
try {
if (value && value.hasOwnProperty("then")) {
msg += ", consider using `promise_test` instead";
if (value && typeof value.then === 'function') {
msg += ' Consider using `promise_test` instead when ' +
'using Promises or async/await.';
}
} catch (err) {}
......@@ -568,7 +569,30 @@ policies and contribution forms [3].
var test_name = name ? name : test_environment.next_default_test_name();
var test_obj = new Test(test_name, properties);
if (func) {
test_obj.step(func, test_obj, test_obj);
var value = test_obj.step(func, test_obj, test_obj);
// Test authors sometimes return values to async_test, expecting us
// to handle the value somehow. Make doing so a harness error to be
// clear this is invalid, and point authors to promise_test if it
// may be appropriate.
//
// Note that we only perform this check on the initial function
// passed to async_test, not on any later steps - we haven't seen a
// consistent problem with those (and it's harder to check).
if (value !== undefined) {
var msg = 'Test named "' + test_name +
'" passed a function to `async_test` that returned a value.';
try {
if (value && typeof value.then === 'function') {
msg += ' Consider using `promise_test` instead when ' +
'using Promises or async/await.';
}
} catch (err) {}
tests.set_status(tests.status.ERROR, msg);
tests.complete();
}
}
return test_obj;
}
......@@ -2069,7 +2093,7 @@ policies and contribution forms [3].
func();
} else {
if(remaining === 0) {
assert(false, "wait_for", description,
assert(false, "step_wait_func", description,
"Timed out waiting on condition");
}
remaining--;
......
CONSOLE ERROR: line 3542: Uncaught Error: assert_equals: Normal script execution order comparison expected "Inline1;Sync1;EndOfBody;DOMContentLoaded;Async1;" but got "EndOfBody;Inline1;Sync1;DOMContentLoaded;Async1;"
CONSOLE ERROR: line 3566: Uncaught Error: assert_equals: Normal script execution order comparison expected "Inline1;Sync1;EndOfBody;DOMContentLoaded;Async1;" but got "EndOfBody;Inline1;Sync1;DOMContentLoaded;Async1;"
This is a testharness.js-based test.
FAIL Async Script Execution Order (wrt possibly deferred Synchronous Script) Uncaught Error: assert_equals: Normal script execution order comparison expected "Inline1;Sync1;EndOfBody;DOMContentLoaded;Async1;" but got "EndOfBody;Inline1;Sync1;DOMContentLoaded;Async1;"
Harness: the test ran to completion.
......
CONSOLE ERROR: line 3542: Uncaught Error: assert_equals: Normal defer script execution order comparison expected "Inline1;Sync1;Inline2;Sync2;EndOfBody;Defer1;Defer2;DOMContentLoaded;" but got "EndOfBody;Inline1;Sync1;Inline2;Sync2;Defer1;Defer2;DOMContentLoaded;"
CONSOLE ERROR: line 3566: Uncaught Error: assert_equals: Normal defer script execution order comparison expected "Inline1;Sync1;Inline2;Sync2;EndOfBody;Defer1;Defer2;DOMContentLoaded;" but got "EndOfBody;Inline1;Sync1;Inline2;Sync2;Defer1;Defer2;DOMContentLoaded;"
This is a testharness.js-based test.
FAIL Defer Script Execution Order Uncaught Error: assert_equals: Normal defer script execution order comparison expected "Inline1;Sync1;Inline2;Sync2;EndOfBody;Defer1;Defer2;DOMContentLoaded;" but got "EndOfBody;Inline1;Sync1;Inline2;Sync2;Defer1;Defer2;DOMContentLoaded;"
Harness: the test ran to completion.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment