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

Roll new WPT js code.

This rolls up to sha d004bddde373550fe9a563487adda3e17fc4c697

Bug: None
Change-Id: I7b92df20ea3462512ff1978a766cf84a09d9e358
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2480143
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820257}
parent 8d7cd411
This is a testharness.js-based test.
FAIL drag-selected-image-to-contenteditable resources/testharness.js:2001:25)
FAIL assertSelection(inputText, tester, expectedText, options) resources/testharness.js:2038: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">
......
......@@ -23,6 +23,7 @@
this.createSource("none");
this.tickIdx = 0;
this.defaultTickDuration = defaultTickDuration;
this.context = null;
}
Actions.prototype = {
......@@ -66,7 +67,17 @@
} catch(e) {
return Promise.reject(e);
}
return test_driver.action_sequence(actions);
return test_driver.action_sequence(actions, this.context);
},
/**
* Set the context for the actions
*
* @param {WindowProxy} context - Context in which to run the action sequence
*/
setContext: function(context) {
this.context = context;
return this;
},
/**
......
(function() {
"use strict";
var idCounter = 0;
let testharness_context = null;
function getInViewCenterPoint(rect) {
var left = Math.max(0, rect.left);
......@@ -48,6 +49,31 @@
* @namespace
*/
window.test_driver = {
/**
* Set the context in which testharness.js is loaded
*
* @param {WindowProxy} context - the window containing testharness.js
**/
set_test_context: function(context) {
if (window.test_driver_internal.set_test_context) {
window.test_driver_internal.set_test_context(context);
}
testharness_context = context;
},
/**
* postMessage to the context containing testharness.js
*
* @param {Object} msg - the data to POST
**/
message_test: function(msg) {
let target = testharness_context;
if (testharness_context === null) {
target = window;
}
target.postMessage(msg, "*");
},
/**
* Trigger user interaction in order to grant additional privileges to
* a provided function.
......@@ -57,30 +83,35 @@
* @param {String} intent - a description of the action which much be
* triggered by user interaction
* @param {Function} action - code requiring escalated privileges
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} fulfilled following user interaction and
* execution of the provided `action` function;
* rejected if interaction fails or the provided
* function throws an error
*/
bless: function(intent, action) {
var button = document.createElement("button");
bless: function(intent, action, context=null) {
let contextDocument = context ? context.document : document;
var button = contextDocument.createElement("button");
button.innerHTML = "This test requires user interaction.<br />" +
"Please click here to allow " + intent + ".";
button.id = "wpt-test-driver-bless-" + (idCounter += 1);
const elem = document.body || document.documentElement;
const elem = contextDocument.body || contextDocument.documentElement;
elem.appendChild(button);
return new Promise(function(resolve, reject) {
button.addEventListener("click", resolve);
let wait_click = new Promise(resolve => button.addEventListener("click", resolve));
test_driver.click(button).catch(reject);
}).then(function() {
return test_driver.click(button)
.then(wait_click)
.then(function() {
button.remove();
if (typeof action === "function") {
return action();
}
return null;
});
},
......@@ -151,10 +182,14 @@
* https://github.com/WICG/page-lifecycle/blob/master/README.md|Lifecycle API
* for Web Pages}
*
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} fulfilled after the freeze request is sent, or rejected
* in case the WebDriver command errors
*/
freeze: function() {
freeze: function(context=null) {
return window.test_driver_internal.freeze();
},
......@@ -166,19 +201,23 @@
* https://w3c.github.io/webdriver/#actions|WebDriver Actions Command}
*
* @param {Array} actions - an array of actions. The format is the same as the actions
property of the WebDriver command {@link
https://w3c.github.io/webdriver/#perform-actions|Perform
Actions} command. Each element is an object representing an
input source and each input source itself has an actions
property detailing the behaviour of that source at each timestep
(or tick). Authors are not expected to construct the actions
sequence by hand, but to use the builder api provided in
testdriver-actions.js
* property of the WebDriver command {@link
* https://w3c.github.io/webdriver/#perform-actions|Perform
* Actions} command. Each element is an object representing an
* input source and each input source itself has an actions
* property detailing the behaviour of that source at each timestep
* (or tick). Authors are not expected to construct the actions
* sequence by hand, but to use the builder api provided in
* testdriver-actions.js
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} fufiled after the actions are performed, or rejected in
* the cases the WebDriver command errors
*/
action_sequence: function(actions) {
return window.test_driver_internal.action_sequence(actions);
action_sequence: function(actions, context=null) {
return window.test_driver_internal.action_sequence(actions, context);
},
/**
......@@ -188,11 +227,15 @@
* by ReportingObserver) for testing purposes, as described in
* {@link https://w3c.github.io/reporting/#generate-test-report-command}
*
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} fulfilled after the report is generated, or
* rejected if the report generation fails
*/
generate_test_report: function(message) {
return window.test_driver_internal.generate_test_report(message);
generate_test_report: function(message, context=null) {
return window.test_driver_internal.generate_test_report(message, context);
},
/**
......@@ -206,6 +249,9 @@
* object
* @param {String} state - the state of the permission
* @param {boolean} one_realm - Optional. Whether the permission applies to only one realm
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* The above params are used to create a [PermissionSetParameters]{@link
* https://w3c.github.io/permissions/#dictdef-permissionsetparameters} object
......@@ -213,13 +259,13 @@
* @returns {Promise} fulfilled after the permission is set, or rejected if setting the
* permission fails
*/
set_permission: function(descriptor, state, one_realm) {
set_permission: function(descriptor, state, one_realm, context=null) {
let permission_params = {
descriptor,
state,
oneRealm: one_realm,
};
return window.test_driver_internal.set_permission(permission_params);
return window.test_driver_internal.set_permission(permission_params, context);
},
/**
......@@ -232,12 +278,16 @@
* @param {Object} config - an [Authenticator Configuration]{@link
* https://w3c.github.io/webauthn/#authenticator-configuration}
* object
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} fulfilled after the authenticator is added, or
* rejected in the cases the WebDriver command
* errors. Returns the ID of the authenticator
*/
add_virtual_authenticator: function(config) {
return window.test_driver_internal.add_virtual_authenticator(config);
add_virtual_authenticator: function(config, context=null) {
return window.test_driver_internal.add_virtual_authenticator(config, context);
},
/**
......@@ -249,13 +299,16 @@
*
* @param {String} authenticator_id - the ID of the authenticator to be
* removed.
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} fulfilled after the authenticator is removed, or
* rejected in the cases the WebDriver command
* errors
*/
remove_virtual_authenticator: function(authenticator_id) {
return window.test_driver_internal.remove_virtual_authenticator(authenticator_id);
remove_virtual_authenticator: function(authenticator_id, context=null) {
return window.test_driver_internal.remove_virtual_authenticator(authenticator_id, context);
},
/**
......@@ -267,13 +320,16 @@
* @param {Object} credential - A [Credential Parameters]{@link
* https://w3c.github.io/webauthn/#credential-parameters}
* object
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} fulfilled after the credential is added, or
* rejected in the cases the WebDriver command
* errors
*/
add_credential: function(authenticator_id, credential) {
return window.test_driver_internal.add_credential(authenticator_id, credential);
add_credential: function(authenticator_id, credential, context=null) {
return window.test_driver_internal.add_credential(authenticator_id, credential, context);
},
/**
......@@ -285,6 +341,9 @@
* https://w3c.github.io/webauthn/#sctn-automation-get-credentials
*
* @param {String} authenticator_id - the ID of the authenticator
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} fulfilled after the credentials are returned, or
* rejected in the cases the WebDriver command
......@@ -292,8 +351,8 @@
* Parameters]{@link
* https://w3c.github.io/webauthn/#credential-parameters}
*/
get_credentials: function(authenticator_id) {
return window.test_driver_internal.get_credentials(authenticator_id);
get_credentials: function(authenticator_id, context=null) {
return window.test_driver_internal.get_credentials(authenticator_id, context=null);
},
/**
......@@ -303,13 +362,16 @@
*
* @param {String} authenticator_id - the ID of the authenticator
* @param {String} credential_id - the ID of the credential
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} fulfilled after the credential is removed, or
* rejected in the cases the WebDriver command
* errors.
*/
remove_credential: function(authenticator_id, credential_id) {
return window.test_driver_internal.remove_credential(authenticator_id, credential_id);
remove_credential: function(authenticator_id, credential_id, context=null) {
return window.test_driver_internal.remove_credential(authenticator_id, credential_id, context);
},
/**
......@@ -318,13 +380,16 @@
* https://w3c.github.io/webauthn/#sctn-automation-remove-all-credentials
*
* @param {String} authenticator_id - the ID of the authenticator
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} fulfilled after the credentials are removed, or
* rejected in the cases the WebDriver command
* errors.
*/
remove_all_credentials: function(authenticator_id) {
return window.test_driver_internal.remove_all_credentials(authenticator_id);
remove_all_credentials: function(authenticator_id, context=null) {
return window.test_driver_internal.remove_all_credentials(authenticator_id, context);
},
/**
......@@ -336,9 +401,12 @@
*
* @param {String} authenticator_id - the ID of the authenticator
* @param {boolean} uv - the User Verified flag
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*/
set_user_verified: function(authenticator_id, uv) {
return window.test_driver_internal.set_user_verified(authenticator_id, uv);
set_user_verified: function(authenticator_id, uv, context=null) {
return window.test_driver_internal.set_user_verified(authenticator_id, uv, context);
},
/**
......@@ -355,16 +423,19 @@
* May be "*" to indicate all origins.
* @param {String} state - The storage access setting.
* Must be either "allowed" or "blocked".
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} Fulfilled after the storage access rule has been
* set, or rejected if setting the rule fails.
*/
set_storage_access: function(origin, embedding_origin, state) {
set_storage_access: function(origin, embedding_origin, state, context=null) {
if (state !== "allowed" && state !== "blocked") {
throw new Error("storage access status must be 'allowed' or 'blocked'");
}
const blocked = state === "blocked";
return window.test_driver_internal.set_storage_access(origin, embedding_origin, blocked);
return window.test_driver_internal.set_storage_access(origin, embedding_origin, blocked, context);
},
};
......@@ -377,13 +448,6 @@
*/
in_automation: false,
/**
* Waits for a user-initiated click
*
* @param {Element} element - element to be clicked
* @param {{x: number, y: number} coords - viewport coordinates to click at
* @returns {Promise} fulfilled after click occurs
*/
click: function(element, coords) {
if (this.in_automation) {
return Promise.reject(new Error('Not implemented'));
......@@ -394,14 +458,6 @@
});
},
/**
* Waits for an element to receive a series of key presses
*
* @param {Element} element - element which should receve key presses
* @param {String} keys - keys to expect
* @returns {Promise} fulfilled after keys are received or rejected if
* an incorrect key sequence is received
*/
send_keys: function(element, keys) {
if (this.in_automation) {
return Promise.reject(new Error('Not implemented'));
......@@ -434,158 +490,52 @@
});
},
/**
* Freeze the current page
*
* @returns {Promise} fulfilled after freeze request is sent, otherwise
* it gets rejected
*/
freeze: function() {
freeze: function(context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Send a sequence of pointer actions
*
* @returns {Promise} fufilled after actions are sent, rejected if any actions
* fail
*/
action_sequence: function(actions) {
action_sequence: function(actions, context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Generates a test report on the current page
*
* @param {String} message - the message to be contained in the report
* @returns {Promise} fulfilled after the report is generated, or
* rejected if the report generation fails
*/
generate_test_report: function(message) {
generate_test_report: function(message, context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Sets the state of a permission
*
* This function simulates a user setting a permission into a particular state as described
* in {@link https://w3c.github.io/permissions/#set-permission-command}
*
* @param {Object} permission_params - a [PermissionSetParameters]{@lint
* https://w3c.github.io/permissions/#dictdef-permissionsetparameters}
* object
* @returns {Promise} fulfilled after the permission is set, or rejected if setting the
* permission fails
*/
set_permission: function(permission_params) {
set_permission: function(permission_params, context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Creates a virtual authenticator
*
* @param {Object} config - the authenticator configuration
* @returns {Promise} fulfilled after the authenticator is added, or
* rejected in the cases the WebDriver command
* errors.
*/
add_virtual_authenticator: function(config) {
add_virtual_authenticator: function(config, context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Removes a virtual authenticator
*
* @param {String} authenticator_id - the ID of the authenticator to be
* removed.
*
* @returns {Promise} fulfilled after the authenticator is removed, or
* rejected in the cases the WebDriver command
* errors
*/
remove_virtual_authenticator: function(authenticator_id) {
remove_virtual_authenticator: function(authenticator_id, context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Adds a credential to a virtual authenticator
*
* @param {String} authenticator_id - the ID of the authenticator
* @param {Object} credential - A [Credential Parameters]{@link
* https://w3c.github.io/webauthn/#credential-parameters}
* object
*
* @returns {Promise} fulfilled after the credential is added, or
* rejected in the cases the WebDriver command
* errors
*
*/
add_credential: function(authenticator_id, credential) {
add_credential: function(authenticator_id, credential, context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Gets all the credentials stored in an authenticator
*
* @param {String} authenticator_id - the ID of the authenticator
*
* @returns {Promise} fulfilled after the credentials are returned, or
* rejected in the cases the WebDriver command
* errors. Returns an array of [Credential
* Parameters]{@link
* https://w3c.github.io/webauthn/#credential-parameters}
*
*/
get_credentials: function(authenticator_id) {
get_credentials: function(authenticator_id, context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Remove a credential stored in an authenticator
*
* @param {String} authenticator_id - the ID of the authenticator
* @param {String} credential_id - the ID of the credential
*
* @returns {Promise} fulfilled after the credential is removed, or
* rejected in the cases the WebDriver command
* errors.
*
*/
remove_credential: function(authenticator_id, credential_id) {
remove_credential: function(authenticator_id, credential_id, context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Removes all the credentials stored in a virtual authenticator
*
* @param {String} authenticator_id - the ID of the authenticator
*
* @returns {Promise} fulfilled after the credentials are removed, or
* rejected in the cases the WebDriver command
* errors.
*
*/
remove_all_credentials: function(authenticator_id) {
remove_all_credentials: function(authenticator_id, context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Sets the User Verified flag on an authenticator
*
* @param {String} authenticator_id - the ID of the authenticator
* @param {boolean} uv - the User Verified flag
*
*/
set_user_verified: function(authenticator_id, uv) {
set_user_verified: function(authenticator_id, uv, context=null) {
return Promise.reject(new Error("unimplemented"));
},
/**
* Sets the storage access policy for a third-party origin when loaded
* in the current first party context
*/
set_storage_access: function(origin, embedding_origin, blocked) {
set_storage_access: function(origin, embedding_origin, blocked, context=null) {
return Promise.reject(new Error("unimplemented"));
},
};
......
......@@ -520,6 +520,43 @@ policies and contribution forms [3].
Object.prototype.toString.call(worker) == '[object ServiceWorker]';
}
var seen_func_name = Object.create(null);
function get_test_name(func, name)
{
if (name) {
return name;
}
if (func) {
var func_code = func.toString();
// Try and match with brackets, but fallback to matching without
var arrow = func_code.match(/^\(\)\s*=>\s*(?:{(.*)}\s*|(.*))$/);
// Check for JS line separators
if (arrow !== null && !/[\u000A\u000D\u2028\u2029]/.test(func_code)) {
var trimmed = (arrow[1] !== undefined ? arrow[1] : arrow[2]).trim();
// drop trailing ; if there's no earlier ones
trimmed = trimmed.replace(/^([^;]*)(;\s*)+$/, "$1");
if (trimmed) {
let name = trimmed;
if (seen_func_name[trimmed]) {
// This subtest name already exists, so add a suffix.
name += " " + seen_func_name[trimmed];
} else {
seen_func_name[trimmed] = 0;
}
seen_func_name[trimmed] += 1;
return name;
}
}
}
return test_environment.next_default_test_name();
}
/*
* API functions
*/
......@@ -530,7 +567,7 @@ policies and contribution forms [3].
tests.status.message = '`test` invoked after `promise_setup`';
tests.complete();
}
var test_name = name ? name : test_environment.next_default_test_name();
var test_name = get_test_name(func, name);
var test_obj = new Test(test_name, properties);
var value = test_obj.step(func, test_obj, test_obj);
......@@ -566,7 +603,7 @@ policies and contribution forms [3].
name = func;
func = null;
}
var test_name = name ? name : test_environment.next_default_test_name();
var test_name = get_test_name(func, name);
var test_obj = new Test(test_name, properties);
if (func) {
var value = test_obj.step(func, test_obj, test_obj);
......@@ -603,7 +640,7 @@ policies and contribution forms [3].
name = func;
func = null;
}
var test_name = name ? name : test_environment.next_default_test_name();
var test_name = get_test_name(func, name);
var test = new Test(test_name, properties);
test._is_promise_test = true;
......@@ -3797,7 +3834,7 @@ policies and contribution forms [3].
function get_title()
{
if ('document' in global_scope) {
//Don't use document.title to work around an Opera bug in XHTML documents
//Don't use document.title to work around an Opera/Presto bug in XHTML documents
var title = document.getElementsByTagName("title")[0];
if (title && title.firstChild && title.firstChild.data) {
return title.firstChild.data;
......
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;"
CONSOLE ERROR: line 3603: 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 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;"
CONSOLE ERROR: line 3603: 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