Skip to content

Commit

Permalink
test: update WPT resources
Browse files Browse the repository at this point in the history
It is mainly an update for idlharness.js, testharness.js, etc.

PR-URL: #44948
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
XadillaX authored and danielleadams committed Jan 3, 2023
1 parent e41a39c commit d86fcbf
Show file tree
Hide file tree
Showing 9 changed files with 284 additions and 143 deletions.
2 changes: 1 addition & 1 deletion test/fixtures/wpt/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The 3-Clause BSD License

Copyright 2019 web-platform-tests contributors
Copyright © web-platform-tests contributors

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Last update:
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/5873f2d8f1/html/webappapis/timers
- interfaces: https://github.com/web-platform-tests/wpt/tree/fc086c82d5/interfaces
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/17ebc3aea0/performance-timeline
- resources: https://github.com/web-platform-tests/wpt/tree/c5b428f15a/resources
- resources: https://github.com/web-platform-tests/wpt/tree/fbf1e7d247/resources
- streams: https://github.com/web-platform-tests/wpt/tree/9e5ef42bd3/streams
- url: https://github.com/web-platform-tests/wpt/tree/0e5b126cd0/url
- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/resources/channel.sub.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@
* @returns {Promise} - Resolved once the channel is disconnected.
*/
disconnectReader() {
// This causes any readers to disconnect until they are explictly reconnected
// This causes any readers to disconnect until they are explicitly reconnected
return this.sendChannel.disconnectReader();
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/resources/idlharness-shadowrealm.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function idl_test_shadowrealm(srcs, deps) {
isWindow: function() { return false; },
isWorker: function() { return false; },
isShadowRealm: function() { return true; },
};
}; undefined;
`);

const ss = await Promise.all(script_urls.map(url => fetch_text(url)));
Expand Down
109 changes: 103 additions & 6 deletions test/fixtures/wpt/resources/idlharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -1529,12 +1529,12 @@ IdlInterface.prototype.test_self = function()
// https://github.com/heycam/webidl/issues/698
assert_true(isConstructor(this.get_interface_object()), "interface object must pass IsConstructor check");

var interface_object = this.get_interface_object();
assert_throws_js(globalOf(interface_object).TypeError, function() {
interface_object();
}, "interface object didn't throw TypeError when called as a function");

if (!this.constructors().length) {
// "If I was not declared with a constructor operation, then throw a TypeError."
var interface_object = this.get_interface_object();
assert_throws_js(globalOf(interface_object).TypeError, function() {
interface_object();
}, "interface object didn't throw TypeError when called as a function");
assert_throws_js(globalOf(interface_object).TypeError, function() {
new interface_object();
}, "interface object didn't throw TypeError when called as a constructor");
Expand Down Expand Up @@ -2458,7 +2458,7 @@ IdlInterface.prototype.test_member_iterable = function(member)
].forEach(([property, length]) => {
var desc = Object.getOwnPropertyDescriptor(proto, property);
assert_equals(typeof desc.value, "function", property + " property should be a function");
assert_equals(desc.value.length, length, property + " function object length should be " + length);
assert_equals(desc.value.length, length, property + " function object should have the right length");
assert_equals(desc.value.name, property, property + " function object should have the right name");
});
} else {
Expand All @@ -2471,6 +2471,97 @@ IdlInterface.prototype.test_member_iterable = function(member)
}.bind(this), this.name + " interface: iterable<" + member.idlType.map(function(t) { return t.idlType; }).join(", ") + ">");
};

IdlInterface.prototype.test_member_maplike = function(member) {
subsetTestByKey(this.name, test, () => {
const proto = this.get_interface_object().prototype;

const methods = [
["entries", 0],
["keys", 0],
["values", 0],
["forEach", 1],
["get", 1],
["has", 1]
];
if (!member.readonly) {
methods.push(
["set", 2],
["delete", 1],
["clear", 1]
);
}

for (const [name, length] of methods) {
const desc = Object.getOwnPropertyDescriptor(proto, name);
assert_equals(typeof desc.value, "function", `${name} should be a function`);
assert_equals(desc.enumerable, false, `${name} enumerable`);
assert_equals(desc.configurable, true, `${name} configurable`);
assert_equals(desc.writable, true, `${name} writable`);
assert_equals(desc.value.length, length, `${name} function object length should be ${length}`);
assert_equals(desc.value.name, name, `${name} function object should have the right name`);
}

const iteratorDesc = Object.getOwnPropertyDescriptor(proto, Symbol.iterator);
assert_equals(iteratorDesc.value, proto.entries, `@@iterator should equal entries`);
assert_equals(iteratorDesc.enumerable, false, `@@iterator enumerable`);
assert_equals(iteratorDesc.configurable, true, `@@iterator configurable`);
assert_equals(iteratorDesc.writable, true, `@@iterator writable`);

const sizeDesc = Object.getOwnPropertyDescriptor(proto, "size");
assert_equals(typeof sizeDesc.get, "function", `size getter should be a function`);
assert_equals(sizeDesc.set, undefined, `size should not have a setter`);
assert_equals(sizeDesc.enumerable, false, `size enumerable`);
assert_equals(sizeDesc.configurable, true, `size configurable`);
assert_equals(sizeDesc.get.length, 0, `size getter length should have the right length`);
assert_equals(sizeDesc.get.name, "get size", `size getter have the right name`);
}, `${this.name} interface: maplike<${member.idlType.map(t => t.idlType).join(", ")}>`);
};

IdlInterface.prototype.test_member_setlike = function(member) {
subsetTestByKey(this.name, test, () => {
const proto = this.get_interface_object().prototype;

const methods = [
["entries", 0],
["keys", 0],
["values", 0],
["forEach", 1],
["has", 1]
];
if (!member.readonly) {
methods.push(
["add", 1],
["delete", 1],
["clear", 1]
);
}

for (const [name, length] of methods) {
const desc = Object.getOwnPropertyDescriptor(proto, name);
assert_equals(typeof desc.value, "function", `${name} should be a function`);
assert_equals(desc.enumerable, false, `${name} enumerable`);
assert_equals(desc.configurable, true, `${name} configurable`);
assert_equals(desc.writable, true, `${name} writable`);
assert_equals(desc.value.length, length, `${name} function object length should be ${length}`);
assert_equals(desc.value.name, name, `${name} function object should have the right name`);
}

const iteratorDesc = Object.getOwnPropertyDescriptor(proto, Symbol.iterator);
assert_equals(iteratorDesc.value, proto.values, `@@iterator should equal values`);
assert_equals(iteratorDesc.enumerable, false, `@@iterator enumerable`);
assert_equals(iteratorDesc.configurable, true, `@@iterator configurable`);
assert_equals(iteratorDesc.writable, true, `@@iterator writable`);

const sizeDesc = Object.getOwnPropertyDescriptor(proto, "size");
assert_equals(typeof sizeDesc.get, "function", `size getter should be a function`);
assert_equals(sizeDesc.set, undefined, `size should not have a setter`);
assert_equals(sizeDesc.enumerable, false, `size enumerable`);
assert_equals(sizeDesc.configurable, true, `size configurable`);
assert_equals(sizeDesc.get.length, 0, `size getter length should have the right length`);
assert_equals(sizeDesc.get.name, "size", `size getter have the right name`);
}, `${this.name} interface: setlike<${member.idlType.map(t => t.idlType).join(", ")}>`);
};

IdlInterface.prototype.test_member_async_iterable = function(member)
{
subsetTestByKey(this.name, test, function()
Expand Down Expand Up @@ -2624,6 +2715,12 @@ IdlInterface.prototype.test_members = function()
this.test_member_iterable(member);
}
break;
case "maplike":
this.test_member_maplike(member);
break;
case "setlike":
this.test_member_setlike(member);
break;
default:
// TODO: check more member types.
break;
Expand Down
30 changes: 15 additions & 15 deletions test/fixtures/wpt/resources/testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@
*
* Typically this function is called implicitly on page load; it's
* only necessary for users to call this when either the
* ``explict_done`` or ``single_page`` properties have been set
* ``explicit_done`` or ``single_page`` properties have been set
* via the :js:func:`setup` function.
*
* For single page tests this marks the test as complete and sets its status.
Expand Down Expand Up @@ -2719,19 +2719,6 @@
* to reduce intermittents without compromising test execution
* speed when the condition is quickly met.
*
* @example
* async_test(t => {
* const popup = window.open("resources/coop-coep.py?coop=same-origin&coep=&navigate=about:blank");
* t.add_cleanup(() => popup.close());
* assert_equals(window, popup.opener);
*
* popup.onload = t.step_func(() => {
* assert_true(popup.location.href.endsWith("&navigate=about:blank"));
* // Use step_wait_func_done as about:blank cannot message back.
* t.step_wait_func_done(() => popup.location.href === "about:blank");
* });
* }, "Navigating a popup to about:blank");
*
* @param {Function} cond A function taking no arguments and
* returning a boolean. The callback is called
* when this function returns true.
Expand Down Expand Up @@ -2774,6 +2761,19 @@
* to reduce intermittents without compromising test execution speed
* when the condition is quickly met.
*
* @example
* async_test(t => {
* const popup = window.open("resources/coop-coep.py?coop=same-origin&coep=&navigate=about:blank");
* t.add_cleanup(() => popup.close());
* assert_equals(window, popup.opener);
*
* popup.onload = t.step_func(() => {
* assert_true(popup.location.href.endsWith("&navigate=about:blank"));
* // Use step_wait_func_done as about:blank cannot message back.
* t.step_wait_func_done(() => popup.location.href === "about:blank");
* });
* }, "Navigating a popup to about:blank");
*
* @param {Function} cond A function taking no arguments and
* returning a boolean. The callback is called
* when this function returns true.
Expand Down Expand Up @@ -3883,7 +3883,7 @@
/**
* Timeout the tests.
*
* This only has an effect when ``explict_timeout`` has been set
* This only has an effect when ``explicit_timeout`` has been set
* in :js:func:`setup`. In other cases any call is a no-op.
*
*/
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/resources/webidl2/lib/VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Currently using webidl2.js@1fd6709ef9311f2ea0ed4ff0016ecf6f5d615104.
Currently using webidl2.js@6889aee6fc7d65915ab1267825248157dbc50486.
Loading

0 comments on commit d86fcbf

Please sign in to comment.