Skip to content

Commit d86fcbf

Browse files
XadillaXdanielleadams
authored andcommitted
test: update WPT resources
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>
1 parent e41a39c commit d86fcbf

File tree

9 files changed

+284
-143
lines changed

9 files changed

+284
-143
lines changed

test/fixtures/wpt/LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The 3-Clause BSD License
22

3-
Copyright 2019 web-platform-tests contributors
3+
Copyright © web-platform-tests contributors
44

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

test/fixtures/wpt/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Last update:
2424
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/5873f2d8f1/html/webappapis/timers
2525
- interfaces: https://github.com/web-platform-tests/wpt/tree/fc086c82d5/interfaces
2626
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/17ebc3aea0/performance-timeline
27-
- resources: https://github.com/web-platform-tests/wpt/tree/c5b428f15a/resources
27+
- resources: https://github.com/web-platform-tests/wpt/tree/fbf1e7d247/resources
2828
- streams: https://github.com/web-platform-tests/wpt/tree/9e5ef42bd3/streams
2929
- url: https://github.com/web-platform-tests/wpt/tree/0e5b126cd0/url
3030
- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing

test/fixtures/wpt/resources/channel.sub.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@
604604
* @returns {Promise} - Resolved once the channel is disconnected.
605605
*/
606606
disconnectReader() {
607-
// This causes any readers to disconnect until they are explictly reconnected
607+
// This causes any readers to disconnect until they are explicitly reconnected
608608
return this.sendChannel.disconnectReader();
609609
}
610610

test/fixtures/wpt/resources/idlharness-shadowrealm.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function idl_test_shadowrealm(srcs, deps) {
3636
isWindow: function() { return false; },
3737
isWorker: function() { return false; },
3838
isShadowRealm: function() { return true; },
39-
};
39+
}; undefined;
4040
`);
4141

4242
const ss = await Promise.all(script_urls.map(url => fetch_text(url)));

test/fixtures/wpt/resources/idlharness.js

+103-6
Original file line numberDiff line numberDiff line change
@@ -1529,12 +1529,12 @@ IdlInterface.prototype.test_self = function()
15291529
// https://github.com/heycam/webidl/issues/698
15301530
assert_true(isConstructor(this.get_interface_object()), "interface object must pass IsConstructor check");
15311531

1532+
var interface_object = this.get_interface_object();
1533+
assert_throws_js(globalOf(interface_object).TypeError, function() {
1534+
interface_object();
1535+
}, "interface object didn't throw TypeError when called as a function");
1536+
15321537
if (!this.constructors().length) {
1533-
// "If I was not declared with a constructor operation, then throw a TypeError."
1534-
var interface_object = this.get_interface_object();
1535-
assert_throws_js(globalOf(interface_object).TypeError, function() {
1536-
interface_object();
1537-
}, "interface object didn't throw TypeError when called as a function");
15381538
assert_throws_js(globalOf(interface_object).TypeError, function() {
15391539
new interface_object();
15401540
}, "interface object didn't throw TypeError when called as a constructor");
@@ -2458,7 +2458,7 @@ IdlInterface.prototype.test_member_iterable = function(member)
24582458
].forEach(([property, length]) => {
24592459
var desc = Object.getOwnPropertyDescriptor(proto, property);
24602460
assert_equals(typeof desc.value, "function", property + " property should be a function");
2461-
assert_equals(desc.value.length, length, property + " function object length should be " + length);
2461+
assert_equals(desc.value.length, length, property + " function object should have the right length");
24622462
assert_equals(desc.value.name, property, property + " function object should have the right name");
24632463
});
24642464
} else {
@@ -2471,6 +2471,97 @@ IdlInterface.prototype.test_member_iterable = function(member)
24712471
}.bind(this), this.name + " interface: iterable<" + member.idlType.map(function(t) { return t.idlType; }).join(", ") + ">");
24722472
};
24732473

2474+
IdlInterface.prototype.test_member_maplike = function(member) {
2475+
subsetTestByKey(this.name, test, () => {
2476+
const proto = this.get_interface_object().prototype;
2477+
2478+
const methods = [
2479+
["entries", 0],
2480+
["keys", 0],
2481+
["values", 0],
2482+
["forEach", 1],
2483+
["get", 1],
2484+
["has", 1]
2485+
];
2486+
if (!member.readonly) {
2487+
methods.push(
2488+
["set", 2],
2489+
["delete", 1],
2490+
["clear", 1]
2491+
);
2492+
}
2493+
2494+
for (const [name, length] of methods) {
2495+
const desc = Object.getOwnPropertyDescriptor(proto, name);
2496+
assert_equals(typeof desc.value, "function", `${name} should be a function`);
2497+
assert_equals(desc.enumerable, false, `${name} enumerable`);
2498+
assert_equals(desc.configurable, true, `${name} configurable`);
2499+
assert_equals(desc.writable, true, `${name} writable`);
2500+
assert_equals(desc.value.length, length, `${name} function object length should be ${length}`);
2501+
assert_equals(desc.value.name, name, `${name} function object should have the right name`);
2502+
}
2503+
2504+
const iteratorDesc = Object.getOwnPropertyDescriptor(proto, Symbol.iterator);
2505+
assert_equals(iteratorDesc.value, proto.entries, `@@iterator should equal entries`);
2506+
assert_equals(iteratorDesc.enumerable, false, `@@iterator enumerable`);
2507+
assert_equals(iteratorDesc.configurable, true, `@@iterator configurable`);
2508+
assert_equals(iteratorDesc.writable, true, `@@iterator writable`);
2509+
2510+
const sizeDesc = Object.getOwnPropertyDescriptor(proto, "size");
2511+
assert_equals(typeof sizeDesc.get, "function", `size getter should be a function`);
2512+
assert_equals(sizeDesc.set, undefined, `size should not have a setter`);
2513+
assert_equals(sizeDesc.enumerable, false, `size enumerable`);
2514+
assert_equals(sizeDesc.configurable, true, `size configurable`);
2515+
assert_equals(sizeDesc.get.length, 0, `size getter length should have the right length`);
2516+
assert_equals(sizeDesc.get.name, "get size", `size getter have the right name`);
2517+
}, `${this.name} interface: maplike<${member.idlType.map(t => t.idlType).join(", ")}>`);
2518+
};
2519+
2520+
IdlInterface.prototype.test_member_setlike = function(member) {
2521+
subsetTestByKey(this.name, test, () => {
2522+
const proto = this.get_interface_object().prototype;
2523+
2524+
const methods = [
2525+
["entries", 0],
2526+
["keys", 0],
2527+
["values", 0],
2528+
["forEach", 1],
2529+
["has", 1]
2530+
];
2531+
if (!member.readonly) {
2532+
methods.push(
2533+
["add", 1],
2534+
["delete", 1],
2535+
["clear", 1]
2536+
);
2537+
}
2538+
2539+
for (const [name, length] of methods) {
2540+
const desc = Object.getOwnPropertyDescriptor(proto, name);
2541+
assert_equals(typeof desc.value, "function", `${name} should be a function`);
2542+
assert_equals(desc.enumerable, false, `${name} enumerable`);
2543+
assert_equals(desc.configurable, true, `${name} configurable`);
2544+
assert_equals(desc.writable, true, `${name} writable`);
2545+
assert_equals(desc.value.length, length, `${name} function object length should be ${length}`);
2546+
assert_equals(desc.value.name, name, `${name} function object should have the right name`);
2547+
}
2548+
2549+
const iteratorDesc = Object.getOwnPropertyDescriptor(proto, Symbol.iterator);
2550+
assert_equals(iteratorDesc.value, proto.values, `@@iterator should equal values`);
2551+
assert_equals(iteratorDesc.enumerable, false, `@@iterator enumerable`);
2552+
assert_equals(iteratorDesc.configurable, true, `@@iterator configurable`);
2553+
assert_equals(iteratorDesc.writable, true, `@@iterator writable`);
2554+
2555+
const sizeDesc = Object.getOwnPropertyDescriptor(proto, "size");
2556+
assert_equals(typeof sizeDesc.get, "function", `size getter should be a function`);
2557+
assert_equals(sizeDesc.set, undefined, `size should not have a setter`);
2558+
assert_equals(sizeDesc.enumerable, false, `size enumerable`);
2559+
assert_equals(sizeDesc.configurable, true, `size configurable`);
2560+
assert_equals(sizeDesc.get.length, 0, `size getter length should have the right length`);
2561+
assert_equals(sizeDesc.get.name, "size", `size getter have the right name`);
2562+
}, `${this.name} interface: setlike<${member.idlType.map(t => t.idlType).join(", ")}>`);
2563+
};
2564+
24742565
IdlInterface.prototype.test_member_async_iterable = function(member)
24752566
{
24762567
subsetTestByKey(this.name, test, function()
@@ -2624,6 +2715,12 @@ IdlInterface.prototype.test_members = function()
26242715
this.test_member_iterable(member);
26252716
}
26262717
break;
2718+
case "maplike":
2719+
this.test_member_maplike(member);
2720+
break;
2721+
case "setlike":
2722+
this.test_member_setlike(member);
2723+
break;
26272724
default:
26282725
// TODO: check more member types.
26292726
break;

test/fixtures/wpt/resources/testharness.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@
11271127
*
11281128
* Typically this function is called implicitly on page load; it's
11291129
* only necessary for users to call this when either the
1130-
* ``explict_done`` or ``single_page`` properties have been set
1130+
* ``explicit_done`` or ``single_page`` properties have been set
11311131
* via the :js:func:`setup` function.
11321132
*
11331133
* For single page tests this marks the test as complete and sets its status.
@@ -2719,19 +2719,6 @@
27192719
* to reduce intermittents without compromising test execution
27202720
* speed when the condition is quickly met.
27212721
*
2722-
* @example
2723-
* async_test(t => {
2724-
* const popup = window.open("resources/coop-coep.py?coop=same-origin&coep=&navigate=about:blank");
2725-
* t.add_cleanup(() => popup.close());
2726-
* assert_equals(window, popup.opener);
2727-
*
2728-
* popup.onload = t.step_func(() => {
2729-
* assert_true(popup.location.href.endsWith("&navigate=about:blank"));
2730-
* // Use step_wait_func_done as about:blank cannot message back.
2731-
* t.step_wait_func_done(() => popup.location.href === "about:blank");
2732-
* });
2733-
* }, "Navigating a popup to about:blank");
2734-
*
27352722
* @param {Function} cond A function taking no arguments and
27362723
* returning a boolean. The callback is called
27372724
* when this function returns true.
@@ -2774,6 +2761,19 @@
27742761
* to reduce intermittents without compromising test execution speed
27752762
* when the condition is quickly met.
27762763
*
2764+
* @example
2765+
* async_test(t => {
2766+
* const popup = window.open("resources/coop-coep.py?coop=same-origin&coep=&navigate=about:blank");
2767+
* t.add_cleanup(() => popup.close());
2768+
* assert_equals(window, popup.opener);
2769+
*
2770+
* popup.onload = t.step_func(() => {
2771+
* assert_true(popup.location.href.endsWith("&navigate=about:blank"));
2772+
* // Use step_wait_func_done as about:blank cannot message back.
2773+
* t.step_wait_func_done(() => popup.location.href === "about:blank");
2774+
* });
2775+
* }, "Navigating a popup to about:blank");
2776+
*
27772777
* @param {Function} cond A function taking no arguments and
27782778
* returning a boolean. The callback is called
27792779
* when this function returns true.
@@ -3883,7 +3883,7 @@
38833883
/**
38843884
* Timeout the tests.
38853885
*
3886-
* This only has an effect when ``explict_timeout`` has been set
3886+
* This only has an effect when ``explicit_timeout`` has been set
38873887
* in :js:func:`setup`. In other cases any call is a no-op.
38883888
*
38893889
*/
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Currently using webidl2.js@1fd6709ef9311f2ea0ed4ff0016ecf6f5d615104.
1+
Currently using webidl2.js@6889aee6fc7d65915ab1267825248157dbc50486.

0 commit comments

Comments
 (0)