Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update hr-time and console wpt #44100

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ 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
- 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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/wpt/console/console-is-a-namespace.any.js
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/wpt/console/console-log-shadowrealm-manual.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<mete charset=utf-8>
<title>Console Logging Manual Test</title>
<p>Open the console inside the developer tools. It should contain one entry saying "test passed".</p>
<script>
const sr = new ShadowRealm();
sr.evaluate(`
console.log("test passed");
`);
</script>
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/wpt/console/console-tests-historical.any.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/wpt/console/idlharness-shadowrealm.window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// META: script=/resources/idlharness-shadowrealm.js

// https://console.spec.whatwg.org/

idl_test_shadowrealm(["console"], []);
14 changes: 14 additions & 0 deletions test/fixtures/wpt/hr-time/clamped-time-origin-isolated.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/clamped-time-origin.js"></script>
</head>
<body>
<script>
// Isolated contexts should be clamped to 5 microseconds.
run_test(/*isolated=*/true);
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
14 changes: 14 additions & 0 deletions test/fixtures/wpt/hr-time/clamped-time-origin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/clamped-time-origin.js"></script>
</head>
<body>
<script>
// Non-isolated contexts should be clamped to 100 microseconds.
run_test(/*isolated=*/false);
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>window.performance.now should not enable timing attacks</title>
<link rel="author" title="W3C" href="http://www.w3.org/" />
<link rel="help" href="http://w3c.github.io/hr-time/#privacy-security"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/timing-attack.js"></script>
<script>
run_test(/*isolated=*/true);
</script>
</head>
<body>
<h1>Description</h1>
<p>The recommended minimum resolution of the Performance interface should be set to 5 microseconds.</p>

<div id="log"></div>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
2 changes: 2 additions & 0 deletions test/fixtures/wpt/hr-time/idlharness-shadowrealm.window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// META: script=/resources/idlharness-shadowrealm.js
idl_test_shadowrealm(["hr-time"], ["html", "dom"]);
33 changes: 33 additions & 0 deletions test/fixtures/wpt/hr-time/navigation-start-post-before-unload.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!doctype html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
function busyWait(millis) {
const start = performance.now();
while (performance.now() < start + millis) {}
}
promise_test(async t => {
const delay = 3000;
const iframe = document.createElement('iframe');
iframe.src = './resources/now_frame.html';
document.body.appendChild(iframe);
await new Promise(resolve => iframe.addEventListener('load', resolve));
iframe.contentWindow.addEventListener('beforeunload', () => {
busyWait(delay);
});
iframe.src = './resources/post.html';
await new Promise(resolve => this.addEventListener('message', ({data}) => {
if (data === 'done')
resolve();
}));

const entry = iframe.contentWindow.performance.getEntriesByType('navigation')[0];
assert_less_than(entry.fetchStart, delay);
}, 'timeOrigin should be set after beforeunload');
</script>
</body>
</html>
30 changes: 30 additions & 0 deletions test/fixtures/wpt/hr-time/resources/clamped-time-origin.js
Original file line number Diff line number Diff line change
@@ -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.');
};
4 changes: 4 additions & 0 deletions test/fixtures/wpt/hr-time/resources/post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE HTML>
<script>
window.parent.postMessage('done');
</script>
42 changes: 42 additions & 0 deletions test/fixtures/wpt/hr-time/resources/timing-attack.js
Original file line number Diff line number Diff line change
@@ -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.');
}
39 changes: 3 additions & 36 deletions test/fixtures/wpt/hr-time/timing-attack.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,14 @@
<link rel="help" href="http://w3c.github.io/hr-time/#privacy-security"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/timing-attack.js"></script>
<script>
test(function() {
function check_resolutions(times, length) {
var end = length - 2;

// we compare each value with the following ones
for (var i = 0; i < end; i++) {
var h1 = times[i];
for (var j = i+1; j < end; j++) {
var h2 = times[j];
var diff = h2 - h1;
assert_true((diff === 0) || ((diff * 1000) >= 5),
"Differences smaller than 5 microseconds: " + diff);
}
}
return true;
}

var times = new Array(10);
var index = 0;
var hrt1, hrt2, hrt;

// 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 5 microseconds.');
}, 'The recommended minimum resolution of the Performance interface has been set to 5 microseconds');
run_test(/*isolated=*/false);
</script>
</head>
<body>
<h1>Description</h1>
<p>The recommended minimum resolution of the Performance interface should be set to 5 microseconds.</p>
<p>The recommended minimum resolution of the Performance interface should be set to 100 microseconds for non-isolated contexts.</p>

<div id="log"></div>

Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"path": "common"
},
"console": {
"commit": "3b1f72e99a91d31551edd2147dc7b564eaf25d72",
"commit": "767ae354642bee1e4d90b28df4480475b9260e14",
"path": "console"
},
"dom/abort": {
Expand All @@ -24,7 +24,7 @@
"path": "FileAPI"
},
"hr-time": {
"commit": "9910784394858a8e34d9eb4e5d00788765abf837",
"commit": "34cafd797e58dad280d20040eee012d49ccfa91f",
"path": "hr-time"
},
"html/webappapis/atob": {
Expand Down Expand Up @@ -68,7 +68,7 @@
"path": "user-timing"
},
"wasm/jsapi": {
"commit": "1dd414c79616489ea021c800eb0375a709e8114e",
"commit": "d8dbe6990bed03ec03beee25069a9347d4c3d6d5",
"path": "wasm/jsapi"
},
"wasm/webapi": {
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/wpt/wasm/jsapi/global/constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/wpt/wasm/jsapi/global/type.tentative.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/wpt/wasm/jsapi/table/type.tentative.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");