Commit 4ed8d3b6 authored by Philip Jägenstedt's avatar Philip Jägenstedt Committed by Commit Bot

Sync LayoutTests/resources/ with LayoutTests/external/wpt/resources/

Roll in the most recent version of:
testharness.js, testdriver.js, idlharness.js.

(webidl2.js has not changed in wpt)

Bug: 866467
Change-Id: I5be57429726e2179e0482514158be0e5ec49be04
Reviewed-on: https://chromium-review.googlesource.com/1146804
Commit-Queue: Philip Jägenstedt <foolip@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577252}
parent ba49b73a
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = 1 duplicate test name: "scheme-blob"
PASS Startup
PASS scheme-blob
PASS scheme-blob
Harness: the test ran to completion.
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = 1 duplicate test name: "scheme-blob"
PASS Startup
PASS scheme-blob
PASS scheme-blob
Harness: the test ran to completion.
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = 1 duplicate test name: "scheme-blob"
PASS Startup
PASS scheme-blob
PASS scheme-blob
Harness: the test ran to completion.
CONSOLE WARNING: Subresource requests using legacy protocols (like `ftp:`) are blocked. Please deliver web-accessible resources over modern protocols like HTTPS. See https://www.chromestatus.com/feature/5709390967472128 for details. CONSOLE WARNING: Subresource requests using legacy protocols (like `ftp:`) are blocked. Please deliver web-accessible resources over modern protocols like HTTPS. See https://www.chromestatus.com/feature/5709390967472128 for details.
CONSOLE WARNING: Subresource requests whose URLs contain embedded credentials (e.g. `https://user:pass@host/`) are blocked. See https://www.chromestatus.com/feature/5669008342777856 for more details. CONSOLE WARNING: Subresource requests whose URLs contain embedded credentials (e.g. `https://user:pass@host/`) are blocked. See https://www.chromestatus.com/feature/5669008342777856 for more details.
This is a testharness.js-based test. This is a testharness.js-based test.
PASS Untitled PASS deprecated-subresource-requests
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -70,6 +70,11 @@ function constValue (cnt) ...@@ -70,6 +70,11 @@ function constValue (cnt)
function minOverloadLength(overloads) function minOverloadLength(overloads)
//@{ //@{
{ {
// "The value of the Function object’s “length” property is
// a Number determined as follows:
// ". . .
// "Return the length of the shortest argument list of the
// entries in S."
if (!overloads.length) { if (!overloads.length) {
return 0; return 0;
} }
...@@ -365,7 +370,8 @@ IdlArray.prototype.internal_add_idls = function(parsed_idls, options) ...@@ -365,7 +370,8 @@ IdlArray.prototype.internal_add_idls = function(parsed_idls, options)
parsed_idls.forEach(function(parsed_idl) parsed_idls.forEach(function(parsed_idl)
{ {
if (parsed_idl.partial && ["interface", "dictionary"].includes(parsed_idl.type)) if (parsed_idl.partial
&& ["interface", "dictionary", "namespace"].includes(parsed_idl.type))
{ {
if (should_skip(parsed_idl.name)) if (should_skip(parsed_idl.name))
{ {
...@@ -459,6 +465,10 @@ IdlArray.prototype.internal_add_idls = function(parsed_idls, options) ...@@ -459,6 +465,10 @@ IdlArray.prototype.internal_add_idls = function(parsed_idls, options)
new IdlInterface(parsed_idl, /* is_callback = */ true, /* is_mixin = */ false); new IdlInterface(parsed_idl, /* is_callback = */ true, /* is_mixin = */ false);
break; break;
case "namespace":
this.members[parsed_idl.name] = new IdlNamespace(parsed_idl);
break;
default: default:
throw parsed_idl.name + ": " + parsed_idl.type + " not yet supported"; throw parsed_idl.name + ": " + parsed_idl.type + " not yet supported";
} }
...@@ -845,7 +855,8 @@ IdlArray.prototype.collapse_partials = function() ...@@ -845,7 +855,8 @@ IdlArray.prototype.collapse_partials = function()
{ {
const originalExists = parsed_idl.name in this.members const originalExists = parsed_idl.name in this.members
&& (this.members[parsed_idl.name] instanceof IdlInterface && (this.members[parsed_idl.name] instanceof IdlInterface
|| this.members[parsed_idl.name] instanceof IdlDictionary); || this.members[parsed_idl.name] instanceof IdlDictionary
|| this.members[parsed_idl.name] instanceof IdlNamespace);
let partialTestName = parsed_idl.name; let partialTestName = parsed_idl.name;
if (!parsed_idl.untested) { if (!parsed_idl.untested) {
...@@ -2255,15 +2266,13 @@ IdlInterface.prototype.do_member_operation_asserts = function(memberHolderObject ...@@ -2255,15 +2266,13 @@ IdlInterface.prototype.do_member_operation_asserts = function(memberHolderObject
// behavior is as follows . . ." // behavior is as follows . . ."
assert_equals(typeof memberHolderObject[member.name], "function", assert_equals(typeof memberHolderObject[member.name], "function",
"property must be a function"); "property must be a function");
// "The value of the Function object’s “length” property is
// a Number determined as follows: const ctors = this.members.filter(function(m) {
// ". . . return m.type == "operation" && m.name == member.name;
// "Return the length of the shortest argument list of the });
// entries in S." assert_equals(
assert_equals(memberHolderObject[member.name].length, memberHolderObject[member.name].length,
minOverloadLength(this.members.filter(function(m) { minOverloadLength(ctors),
return m.type == "operation" && m.name == member.name;
})),
"property has wrong .length"); "property has wrong .length");
// Make some suitable arguments // Make some suitable arguments
...@@ -3012,5 +3021,179 @@ function IdlTypedef(obj) ...@@ -3012,5 +3021,179 @@ function IdlTypedef(obj)
IdlTypedef.prototype = Object.create(IdlObject.prototype); IdlTypedef.prototype = Object.create(IdlObject.prototype);
/// IdlNamespace ///
function IdlNamespace(obj)
//@{
{
this.name = obj.name;
this.extAttrs = obj.extAttrs;
this.untested = obj.untested;
/** A back-reference to our IdlArray. */
this.array = obj.array;
/** An array of IdlInterfaceMembers. */
this.members = obj.members.map(m => new IdlInterfaceMember(m));
}
//@}
IdlNamespace.prototype = Object.create(IdlObject.prototype);
IdlNamespace.prototype.do_member_operation_asserts = function (memberHolderObject, member, a_test)
//@{
{
var desc = Object.getOwnPropertyDescriptor(memberHolderObject, member.name);
assert_false("get" in desc, "property should not have a getter");
assert_false("set" in desc, "property should not have a setter");
assert_equals(
desc.writable,
!member.isUnforgeable,
"property should be writable if and only if not unforgeable");
assert_true(desc.enumerable, "property should be enumerable");
assert_equals(
desc.configurable,
!member.isUnforgeable,
"property should be configurable if and only if not unforgeable");
assert_equals(
typeof memberHolderObject[member.name],
"function",
"property must be a function");
assert_equals(
memberHolderObject[member.name].length,
minOverloadLength(this.members.filter(function(m) {
return m.type == "operation" && m.name == member.name;
})),
"operation has wrong .length");
a_test.done();
}
//@}
IdlNamespace.prototype.test_member_operation = function(member)
//@{
{
if (!shouldRunSubTest(this.name)) {
return;
}
var args = member.arguments.map(function(a) {
var s = a.idlType.idlType;
if (a.variadic) {
s += '...';
}
return s;
}).join(", ");
var a_test = subsetTestByKey(
this.name,
async_test,
this.name + ' namespace: operation ' + member.name + '(' + args + ')');
a_test.step(function() {
assert_own_property(
self[this.name],
member.name,
'namespace object missing operation ' + format_value(member.name));
this.do_member_operation_asserts(self[this.name], member, a_test);
}.bind(this));
};
//@}
IdlNamespace.prototype.test_member_attribute = function (member)
//@{
{
if (!shouldRunSubTest(this.name)) {
return;
}
var a_test = subsetTestByKey(
this.name,
async_test,
this.name + ' namespace: attribute ' + member.name);
a_test.step(function()
{
assert_own_property(
self[this.name],
member.name,
this.name + ' does not have property ' + format_value(member.name));
var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name);
assert_equals(desc.set, undefined, "setter must be undefined for namespace members");
a_test.done();
}.bind(this));
};
//@}
IdlNamespace.prototype.test = function ()
//@{
{
/**
* TODO(lukebjerring): Assert:
* - "Note that unlike interfaces or dictionaries, namespaces do not create types."
* - "Of the extended attributes defined in this specification, only the
* [Exposed] and [SecureContext] extended attributes are applicable to namespaces."
* - "Namespaces must be annotated with the [Exposed] extended attribute."
*/
for (const v of Object.values(this.members)) {
switch (v.type) {
case 'operation':
this.test_member_operation(v);
break;
case 'attribute':
this.test_member_attribute(v);
break;
default:
throw 'Invalid namespace member ' + v.name + ': ' + v.type + ' not supported';
}
};
};
//@}
}()); }());
/**
* idl_test is a promise_test wrapper that handles the fetching of the IDL,
* avoiding repetitive boilerplate.
*
* @param {String|String[]} srcs Spec name(s) for source idl files (fetched from
* /interfaces/{name}.idl).
* @param {String|String[]} deps Spec name(s) for dependency idl files (fetched
* from /interfaces/{name}.idl). Order is important - dependencies from
* each source will only be included if they're already know to be a
* dependency (i.e. have already been seen).
* @param {Function} setup_func Function for extra setup of the idl_array, such
* as adding objects. Do not call idl_array.test() in the setup; it is
* called by this function (idl_test).
*/
function idl_test(srcs, deps, idl_setup_func, test_name) {
return promise_test(function (t) {
var idl_array = new IdlArray();
srcs = (srcs instanceof Array) ? srcs : [srcs] || [];
deps = (deps instanceof Array) ? deps : [deps] || [];
return Promise.all(
srcs.concat(deps).map(function(spec) {
return fetch('/interfaces/' + spec + '.idl').then(function(r) {
return r.text();
});
}))
.then(function(idls) {
for (var i = 0; i < srcs.length; i++) {
idl_array.add_idls(idls[i]);
}
for (var i = srcs.length; i < srcs.length + deps.length; i++) {
idl_array.add_dependency_idls(idls[i]);
}
})
.then(function() {
return idl_setup_func(idl_array, t);
})
.then(function() { idl_array.test(); })
.catch(function (reason) {
idl_array.test(); // Test what we can.
return Promise.reject(reason || 'IDL setup failed.');
});
}, test_name);
}
// vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@} foldmethod=marker: // vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@} foldmethod=marker:
(function() { (function() {
"use strict"; "use strict";
var idCounter = 0;
function getInViewCenterPoint(rect) { function getInViewCenterPoint(rect) {
var left = Math.max(0, rect.left); var left = Math.max(0, rect.left);
...@@ -46,6 +47,41 @@ ...@@ -46,6 +47,41 @@
* @namespace * @namespace
*/ */
window.test_driver = { window.test_driver = {
/**
* Trigger user interaction in order to grant additional privileges to
* a provided function.
*
* https://html.spec.whatwg.org/#triggered-by-user-activation
*
* @param {String} intent - a description of the action which much be
* triggered by user interaction
* @param {Function} action - code requiring escalated privileges
*
* @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");
button.innerHTML = "This test requires user interaction.<br />" +
"Please click here to allow " + intent + ".";
button.id = "wpt-test-driver-bless-" + (idCounter += 1);
document.body.appendChild(button);
return new Promise(function(resolve, reject) {
button.addEventListener("click", resolve);
test_driver.click(button).catch(reject);
}).then(function() {
button.remove();
if (typeof action === "function") {
return action();
}
});
},
/** /**
* Triggers a user-initiated click * Triggers a user-initiated click
* *
......
...@@ -213,12 +213,9 @@ policies and contribution forms [3]. ...@@ -213,12 +213,9 @@ policies and contribution forms [3].
} }
WindowTestEnvironment.prototype.next_default_test_name = function() { WindowTestEnvironment.prototype.next_default_test_name = function() {
//Don't use document.title to work around an Opera bug in XHTML documents
var title = document.getElementsByTagName("title")[0];
var prefix = (title && title.firstChild && title.firstChild.data) || "Untitled";
var suffix = this.name_counter > 0 ? " " + this.name_counter : ""; var suffix = this.name_counter > 0 ? " " + this.name_counter : "";
this.name_counter++; this.name_counter++;
return prefix + suffix; return get_title() + suffix;
}; };
WindowTestEnvironment.prototype.on_new_harness_properties = function(properties) { WindowTestEnvironment.prototype.on_new_harness_properties = function(properties) {
...@@ -288,7 +285,7 @@ policies and contribution forms [3]. ...@@ -288,7 +285,7 @@ policies and contribution forms [3].
WorkerTestEnvironment.prototype.next_default_test_name = function() { WorkerTestEnvironment.prototype.next_default_test_name = function() {
var suffix = this.name_counter > 0 ? " " + this.name_counter : ""; var suffix = this.name_counter > 0 ? " " + this.name_counter : "";
this.name_counter++; this.name_counter++;
return "Untitled" + suffix; return get_title() + suffix;
}; };
WorkerTestEnvironment.prototype.on_new_harness_properties = function() {}; WorkerTestEnvironment.prototype.on_new_harness_properties = function() {};
...@@ -1000,6 +997,9 @@ policies and contribution forms [3]. ...@@ -1000,6 +997,9 @@ policies and contribution forms [3].
function assert_object_equals(actual, expected, description) function assert_object_equals(actual, expected, description)
{ {
assert(typeof actual === "object" && actual !== null, "assert_object_equals", description,
"value is ${actual}, expected object",
{actual: actual});
//This needs to be improved a great deal //This needs to be improved a great deal
function check_equal(actual, expected, stack) function check_equal(actual, expected, stack)
{ {
...@@ -1833,6 +1833,15 @@ policies and contribution forms [3]. ...@@ -1833,6 +1833,15 @@ policies and contribution forms [3].
} }
this.message_target.removeEventListener("message", this.message_handler); this.message_target.removeEventListener("message", this.message_handler);
this.running = false; this.running = false;
// If remote context is cross origin assigning to onerror is not
// possible, so silently catch those errors.
try {
this.remote.onerror = null;
} catch (e) {
// Ignore.
}
this.remote = null; this.remote = null;
this.message_target = null; this.message_target = null;
if (this.doneResolve) { if (this.doneResolve) {
...@@ -2917,6 +2926,25 @@ policies and contribution forms [3]. ...@@ -2917,6 +2926,25 @@ policies and contribution forms [3].
return undefined; return undefined;
} }
/** Returns the <title> or filename or "Untitled" */
function get_title()
{
if ('document' in global_scope) {
//Don't use document.title to work around an Opera bug in XHTML documents
var title = document.getElementsByTagName("title")[0];
if (title && title.firstChild && title.firstChild.data) {
return title.firstChild.data;
}
}
if ('META_TITLE' in global_scope && META_TITLE) {
return META_TITLE;
}
if ('location' in global_scope) {
return location.pathname.substring(location.pathname.lastIndexOf('/') + 1, location.pathname.indexOf('.'));
}
return "Untitled";
}
function supports_post_message(w) function supports_post_message(w)
{ {
var supports; var supports;
......
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