From 14d119770019e89fdf643bab8a5af6e9a222c78f Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Tue, 2 Aug 2022 10:02:20 -0400 Subject: [PATCH 1/3] test: update console web platform tests --- test/fixtures/wpt/README.md | 2 +- .../fixtures/wpt/console/console-is-a-namespace.any.js | 3 ++- .../wpt/console/console-log-shadowrealm-manual.html | 10 ++++++++++ .../console-namespace-object-class-string.any.js | 2 +- .../wpt/console/console-tests-historical.any.js | 1 + .../wpt/console/idlharness-shadowrealm.window.js | 5 +++++ test/fixtures/wpt/versions.json | 2 +- 7 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/wpt/console/console-log-shadowrealm-manual.html create mode 100644 test/fixtures/wpt/console/idlharness-shadowrealm.window.js diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 8e5c4f9282f9e4..250090ddbb90b9 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -11,7 +11,7 @@ See [test/wpt](../../wpt/README.md) for information on how these tests are run. Last update: - common: https://github.com/web-platform-tests/wpt/tree/03c5072aff/common -- console: https://github.com/web-platform-tests/wpt/tree/3b1f72e99a/console +- console: https://github.com/web-platform-tests/wpt/tree/767ae35464/console - dom/abort: https://github.com/web-platform-tests/wpt/tree/c49cafb491/dom/abort - dom/events: https://github.com/web-platform-tests/wpt/tree/f8821adb28/dom/events - encoding: https://github.com/web-platform-tests/wpt/tree/c1b24fce6e/encoding diff --git a/test/fixtures/wpt/console/console-is-a-namespace.any.js b/test/fixtures/wpt/console/console-is-a-namespace.any.js index a4aae7ffce8ac8..1756ba6bc1b27d 100644 --- a/test/fixtures/wpt/console/console-is-a-namespace.any.js +++ b/test/fixtures/wpt/console/console-is-a-namespace.any.js @@ -1,5 +1,6 @@ +// META: global=window,dedicatedworker,shadowrealm "use strict"; -// https://heycam.github.io/webidl/#es-namespaces +// https://webidl.spec.whatwg.org/#es-namespaces // https://console.spec.whatwg.org/#console-namespace test(() => { diff --git a/test/fixtures/wpt/console/console-log-shadowrealm-manual.html b/test/fixtures/wpt/console/console-log-shadowrealm-manual.html new file mode 100644 index 00000000000000..b091a850c0c94f --- /dev/null +++ b/test/fixtures/wpt/console/console-log-shadowrealm-manual.html @@ -0,0 +1,10 @@ + + +Console Logging Manual Test +

Open the console inside the developer tools. It should contain one entry saying "test passed".

+ diff --git a/test/fixtures/wpt/console/console-namespace-object-class-string.any.js b/test/fixtures/wpt/console/console-namespace-object-class-string.any.js index 7b27e72d819251..d3ff7f7d076361 100644 --- a/test/fixtures/wpt/console/console-namespace-object-class-string.any.js +++ b/test/fixtures/wpt/console/console-namespace-object-class-string.any.js @@ -1,5 +1,5 @@ "use strict"; -// https://heycam.github.io/webidl/#es-namespaces +// https://webidl.spec.whatwg.org/#es-namespaces // https://console.spec.whatwg.org/#console-namespace test(() => { diff --git a/test/fixtures/wpt/console/console-tests-historical.any.js b/test/fixtures/wpt/console/console-tests-historical.any.js index 4c4d4c276d0cd4..1b18a9879fb080 100644 --- a/test/fixtures/wpt/console/console-tests-historical.any.js +++ b/test/fixtures/wpt/console/console-tests-historical.any.js @@ -1,3 +1,4 @@ +// META: global=window,dedicatedworker,shadowrealm /** * These tests assert the non-existence of certain * legacy Console methods that are not included in diff --git a/test/fixtures/wpt/console/idlharness-shadowrealm.window.js b/test/fixtures/wpt/console/idlharness-shadowrealm.window.js new file mode 100644 index 00000000000000..8f68252dcd2b13 --- /dev/null +++ b/test/fixtures/wpt/console/idlharness-shadowrealm.window.js @@ -0,0 +1,5 @@ +// META: script=/resources/idlharness-shadowrealm.js + +// https://console.spec.whatwg.org/ + +idl_test_shadowrealm(["console"], []); diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index 9a8ed7c4816001..fcfd7b302751bd 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -4,7 +4,7 @@ "path": "common" }, "console": { - "commit": "3b1f72e99a91d31551edd2147dc7b564eaf25d72", + "commit": "767ae354642bee1e4d90b28df4480475b9260e14", "path": "console" }, "dom/abort": { From a000fd86f2db394486361a9ec9f1386218594432 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Tue, 2 Aug 2022 10:17:09 -0400 Subject: [PATCH 2/3] test: update hr-time web platform tests --- test/fixtures/wpt/README.md | 2 +- .../clamped-time-origin-isolated.https.html | 14 +++++++ ...ed-time-origin-isolated.https.html.headers | 2 + .../wpt/hr-time/clamped-time-origin.html | 14 +++++++ ...s-origin-isolated-timing-attack.https.html | 22 ++++++++++ ...-isolated-timing-attack.https.html.headers | 2 + .../hr-time/idlharness-shadowrealm.window.js | 2 + .../navigation-start-post-before-unload.html | 33 +++++++++++++++ .../hr-time/resources/clamped-time-origin.js | 30 +++++++++++++ test/fixtures/wpt/hr-time/resources/post.html | 4 ++ .../wpt/hr-time/resources/timing-attack.js | 42 +++++++++++++++++++ test/fixtures/wpt/hr-time/timing-attack.html | 39 ++--------------- test/fixtures/wpt/versions.json | 2 +- 13 files changed, 170 insertions(+), 38 deletions(-) create mode 100644 test/fixtures/wpt/hr-time/clamped-time-origin-isolated.https.html create mode 100644 test/fixtures/wpt/hr-time/clamped-time-origin-isolated.https.html.headers create mode 100644 test/fixtures/wpt/hr-time/clamped-time-origin.html create mode 100644 test/fixtures/wpt/hr-time/cross-origin-isolated-timing-attack.https.html create mode 100644 test/fixtures/wpt/hr-time/cross-origin-isolated-timing-attack.https.html.headers create mode 100644 test/fixtures/wpt/hr-time/idlharness-shadowrealm.window.js create mode 100644 test/fixtures/wpt/hr-time/navigation-start-post-before-unload.html create mode 100644 test/fixtures/wpt/hr-time/resources/clamped-time-origin.js create mode 100644 test/fixtures/wpt/hr-time/resources/post.html create mode 100644 test/fixtures/wpt/hr-time/resources/timing-attack.js diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 250090ddbb90b9..648298db082395 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -16,7 +16,7 @@ Last update: - dom/events: https://github.com/web-platform-tests/wpt/tree/f8821adb28/dom/events - encoding: https://github.com/web-platform-tests/wpt/tree/c1b24fce6e/encoding - FileAPI: https://github.com/web-platform-tests/wpt/tree/3b279420d4/FileAPI -- hr-time: https://github.com/web-platform-tests/wpt/tree/9910784394/hr-time +- hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time - html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob - html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing - html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/47d3fb280c/html/webappapis/structured-clone diff --git a/test/fixtures/wpt/hr-time/clamped-time-origin-isolated.https.html b/test/fixtures/wpt/hr-time/clamped-time-origin-isolated.https.html new file mode 100644 index 00000000000000..ce30698b77ae3f --- /dev/null +++ b/test/fixtures/wpt/hr-time/clamped-time-origin-isolated.https.html @@ -0,0 +1,14 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/test/fixtures/wpt/hr-time/clamped-time-origin-isolated.https.html.headers b/test/fixtures/wpt/hr-time/clamped-time-origin-isolated.https.html.headers new file mode 100644 index 00000000000000..5f8621ef83660c --- /dev/null +++ b/test/fixtures/wpt/hr-time/clamped-time-origin-isolated.https.html.headers @@ -0,0 +1,2 @@ +Cross-Origin-Embedder-Policy: require-corp +Cross-Origin-Opener-Policy: same-origin diff --git a/test/fixtures/wpt/hr-time/clamped-time-origin.html b/test/fixtures/wpt/hr-time/clamped-time-origin.html new file mode 100644 index 00000000000000..1f438e9fefc0ff --- /dev/null +++ b/test/fixtures/wpt/hr-time/clamped-time-origin.html @@ -0,0 +1,14 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/test/fixtures/wpt/hr-time/cross-origin-isolated-timing-attack.https.html b/test/fixtures/wpt/hr-time/cross-origin-isolated-timing-attack.https.html new file mode 100644 index 00000000000000..88848740a90cee --- /dev/null +++ b/test/fixtures/wpt/hr-time/cross-origin-isolated-timing-attack.https.html @@ -0,0 +1,22 @@ + + + + +window.performance.now should not enable timing attacks + + + + + + + + +

Description

+

The recommended minimum resolution of the Performance interface should be set to 5 microseconds.

+ +
+ + + diff --git a/test/fixtures/wpt/hr-time/cross-origin-isolated-timing-attack.https.html.headers b/test/fixtures/wpt/hr-time/cross-origin-isolated-timing-attack.https.html.headers new file mode 100644 index 00000000000000..5f8621ef83660c --- /dev/null +++ b/test/fixtures/wpt/hr-time/cross-origin-isolated-timing-attack.https.html.headers @@ -0,0 +1,2 @@ +Cross-Origin-Embedder-Policy: require-corp +Cross-Origin-Opener-Policy: same-origin diff --git a/test/fixtures/wpt/hr-time/idlharness-shadowrealm.window.js b/test/fixtures/wpt/hr-time/idlharness-shadowrealm.window.js new file mode 100644 index 00000000000000..3209db5f41b721 --- /dev/null +++ b/test/fixtures/wpt/hr-time/idlharness-shadowrealm.window.js @@ -0,0 +1,2 @@ +// META: script=/resources/idlharness-shadowrealm.js +idl_test_shadowrealm(["hr-time"], ["html", "dom"]); diff --git a/test/fixtures/wpt/hr-time/navigation-start-post-before-unload.html b/test/fixtures/wpt/hr-time/navigation-start-post-before-unload.html new file mode 100644 index 00000000000000..88ee5db77eb0e6 --- /dev/null +++ b/test/fixtures/wpt/hr-time/navigation-start-post-before-unload.html @@ -0,0 +1,33 @@ + + + + + + + + + + diff --git a/test/fixtures/wpt/hr-time/resources/clamped-time-origin.js b/test/fixtures/wpt/hr-time/resources/clamped-time-origin.js new file mode 100644 index 00000000000000..09967ed6d17ec0 --- /dev/null +++ b/test/fixtures/wpt/hr-time/resources/clamped-time-origin.js @@ -0,0 +1,30 @@ +const run_test = isolated => { + // Multiplier to convert the clamped timestamps to microseconds. + const multiplier = 1000; + const windowOrigin = performance.timeOrigin; + // Clamp to at least 5 microseconds in isolated contexts and at least 100 in + // non-isolated ones. + const resolution = isolated ? 5 : 100; + + const create_worker = () => { + return new Promise(resolve => { + const workerScript = 'postMessage({timeOrigin: performance.timeOrigin})'; + const blob = new Blob([workerScript]); + const worker = new Worker(URL.createObjectURL(blob)); + worker.addEventListener('message', event => { + resolve(event.data.timeOrigin); + }); + }); + }; + promise_test(async t => { + assert_equals(self.crossOriginIsolated, isolated, + "crossOriginIsolated is properly set"); + let prev = windowOrigin; + let current; + for (let i = 1; i < 100; ++i) { + current = await create_worker(); + assert_true(current === prev || current - prev > resolution / 1000); + prev = current; + } + }, 'timeOrigins are clamped.'); +}; diff --git a/test/fixtures/wpt/hr-time/resources/post.html b/test/fixtures/wpt/hr-time/resources/post.html new file mode 100644 index 00000000000000..b8541016dd776b --- /dev/null +++ b/test/fixtures/wpt/hr-time/resources/post.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/test/fixtures/wpt/hr-time/resources/timing-attack.js b/test/fixtures/wpt/hr-time/resources/timing-attack.js new file mode 100644 index 00000000000000..f1fc786903a864 --- /dev/null +++ b/test/fixtures/wpt/hr-time/resources/timing-attack.js @@ -0,0 +1,42 @@ +function run_test(isolated) { + let resolution = 100; + if (isolated) { + resolution = 5; + } + test(function() { + function check_resolutions(times, length) { + const end = length - 2; + + // we compare each value with the following ones + for (let i = 0; i < end; i++) { + const h1 = times[i]; + for (let j = i+1; j < end; j++) { + const h2 = times[j]; + const diff = h2 - h1; + assert_true((diff === 0) || ((diff * 1000) >= resolution), + "Differences smaller than ' + resolution + ' microseconds: " + diff); + } + } + return true; + } + + const times = new Array(10); + let index = 0; + let hrt1, hrt2, hrt; + assert_equals(self.crossOriginIsolated, isolated, "Document cross-origin isolated value matches"); + + // rapid firing of performance.now + hrt1 = performance.now(); + hrt2 = performance.now(); + times[index++] = hrt1; + times[index++] = hrt2; + + // ensure that we get performance.now() to return a different value + do { + hrt = performance.now(); + times[index++] = hrt; + } while ((hrt - hrt1) === 0); + + assert_true(check_resolutions(times, index), 'Difference should be at least ' + resolution + ' microseconds.'); + }, 'The recommended minimum resolution of the Performance interface has been set to ' + resolution + ' microseconds for cross-origin isolated contexts.'); +} diff --git a/test/fixtures/wpt/hr-time/timing-attack.html b/test/fixtures/wpt/hr-time/timing-attack.html index 71ade4a8c48ce2..6352b4dbe37e75 100644 --- a/test/fixtures/wpt/hr-time/timing-attack.html +++ b/test/fixtures/wpt/hr-time/timing-attack.html @@ -7,47 +7,14 @@ +

Description

-

The recommended minimum resolution of the Performance interface should be set to 5 microseconds.

+

The recommended minimum resolution of the Performance interface should be set to 100 microseconds for non-isolated contexts.

diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index fcfd7b302751bd..63fa4da214d049 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -24,7 +24,7 @@ "path": "FileAPI" }, "hr-time": { - "commit": "9910784394858a8e34d9eb4e5d00788765abf837", + "commit": "34cafd797e58dad280d20040eee012d49ccfa91f", "path": "hr-time" }, "html/webappapis/atob": { From 0b86fec154ae17629ea62e83c8085597be967779 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Tue, 2 Aug 2022 10:26:34 -0400 Subject: [PATCH 3/3] test: update wasm/jsapi web platform tests --- test/fixtures/wpt/README.md | 2 +- test/fixtures/wpt/versions.json | 2 +- test/fixtures/wpt/wasm/jsapi/global/constructor.any.js | 5 +++++ test/fixtures/wpt/wasm/jsapi/global/type.tentative.any.js | 8 ++++---- test/fixtures/wpt/wasm/jsapi/table/type.tentative.any.js | 8 ++++---- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 648298db082395..e20877de174d43 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -27,7 +27,7 @@ Last update: - streams: https://github.com/web-platform-tests/wpt/tree/8f60d94439/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 -- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/1dd414c796/wasm/jsapi +- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi - WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/cdd0f03df4/WebCryptoAPI - webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index 63fa4da214d049..ca900307b7a597 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -68,7 +68,7 @@ "path": "user-timing" }, "wasm/jsapi": { - "commit": "1dd414c79616489ea021c800eb0375a709e8114e", + "commit": "d8dbe6990bed03ec03beee25069a9347d4c3d6d5", "path": "wasm/jsapi" }, "wasm/webapi": { diff --git a/test/fixtures/wpt/wasm/jsapi/global/constructor.any.js b/test/fixtures/wpt/wasm/jsapi/global/constructor.any.js index f536f5d7b5df6c..dade7b1f55a433 100644 --- a/test/fixtures/wpt/wasm/jsapi/global/constructor.any.js +++ b/test/fixtures/wpt/wasm/jsapi/global/constructor.any.js @@ -87,6 +87,11 @@ test(() => { } }, "Invalid type argument"); +test(() => { + const argument = { "value": "v128" }; + assert_throws_js(TypeError, () => new WebAssembly.Global(argument)); +}, "Construct v128 global"); + test(() => { const argument = { "value": "i64" }; const global = new WebAssembly.Global(argument); diff --git a/test/fixtures/wpt/wasm/jsapi/global/type.tentative.any.js b/test/fixtures/wpt/wasm/jsapi/global/type.tentative.any.js index 173af647f27dc7..95adc2af0f6813 100644 --- a/test/fixtures/wpt/wasm/jsapi/global/type.tentative.any.js +++ b/test/fixtures/wpt/wasm/jsapi/global/type.tentative.any.js @@ -50,12 +50,12 @@ test(() => { }, "externref, immutable") test(() => { - assert_type({"value": "anyfunc", "mutable": true}) -}, "anyfunc, mutable") + assert_type({"value": "funcref", "mutable": true}) +}, "funcref, mutable") test(() => { - assert_type({"value": "anyfunc", "mutable": false}) -}, "anyfunc, immutable") + assert_type({"value": "funcref", "mutable": false}) +}, "funcref, immutable") test(() => { const myglobal = new WebAssembly.Global({"value": "i32", "mutable": true}); diff --git a/test/fixtures/wpt/wasm/jsapi/table/type.tentative.any.js b/test/fixtures/wpt/wasm/jsapi/table/type.tentative.any.js index 596e10b6bf548e..ef1ceecb17d695 100644 --- a/test/fixtures/wpt/wasm/jsapi/table/type.tentative.any.js +++ b/test/fixtures/wpt/wasm/jsapi/table/type.tentative.any.js @@ -10,17 +10,17 @@ function assert_type(argument) { } test(() => { - assert_type({ "minimum": 0, "element": "anyfunc"}); + assert_type({ "minimum": 0, "element": "funcref"}); }, "Zero initial, no maximum"); test(() => { - assert_type({ "minimum": 5, "element": "anyfunc" }); + assert_type({ "minimum": 5, "element": "funcref" }); }, "Non-zero initial, no maximum"); test(() => { - assert_type({ "minimum": 0, "maximum": 0, "element": "anyfunc" }); + assert_type({ "minimum": 0, "maximum": 0, "element": "funcref" }); }, "Zero maximum"); test(() => { - assert_type({ "minimum": 0, "maximum": 5, "element": "anyfunc" }); + assert_type({ "minimum": 0, "maximum": 5, "element": "funcref" }); }, "Non-zero maximum");