GeezerVison is showing github.com — test: update hr-time web platform tests · nodejs/node@ba1915d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/README.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -16,7 +16,7 @@ Last update: | 16 | 16 | - dom/events: https://github.com/web-platform-tests/wpt/tree/f8821adb28/dom/events | 17 | 17 | - encoding: https://github.com/web-platform-tests/wpt/tree/c1b24fce6e/encoding | 18 | 18 | - FileAPI: https://github.com/web-platform-tests/wpt/tree/3b279420d4/FileAPI | 19 | | -- hr-time: https://github.com/web-platform-tests/wpt/tree/9910784394/hr-time | | 19 | +- hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time | 20 | 20 | - html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob | 21 | 21 | - html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing | 22 | 22 | - html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/47d3fb280c/html/webappapis/structured-clone | |
Collapse file Copy file name to clipboard +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!doctype html> | | 2 | +<html> | | 3 | +<head> | | 4 | +<script src="/resources/testharness.js"></script> | | 5 | +<script src="/resources/testharnessreport.js"></script> | | 6 | +<script src="resources/clamped-time-origin.js"></script> | | 7 | +</head> | | 8 | +<body> | | 9 | +<script> | | 10 | +// Isolated contexts should be clamped to 5 microseconds. | | 11 | +run_test(/*isolated=*/true); | | 12 | +</script> | | 13 | +</body> | | 14 | +</html> |
Collapse file Copy file name to clipboard +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Cross-Origin-Embedder-Policy: require-corp | | 2 | +Cross-Origin-Opener-Policy: same-origin |
Collapse file Copy file name to clipboard +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!doctype html> | | 2 | +<html> | | 3 | +<head> | | 4 | +<script src="/resources/testharness.js"></script> | | 5 | +<script src="/resources/testharnessreport.js"></script> | | 6 | +<script src="resources/clamped-time-origin.js"></script> | | 7 | +</head> | | 8 | +<body> | | 9 | +<script> | | 10 | +// Non-isolated contexts should be clamped to 100 microseconds. | | 11 | +run_test(/*isolated=*/false); | | 12 | +</script> | | 13 | +</body> | | 14 | +</html> |
Collapse file Copy file name to clipboard +22Lines changed: 22 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | +<meta charset="utf-8" /> | | 5 | +<title>window.performance.now should not enable timing attacks</title> | | 6 | +<link rel="author" title="W3C" href="http://www.w3.org/" /> | | 7 | +<link rel="help" href="http://w3c.github.io/hr-time/#privacy-security"/> | | 8 | +<script src="/resources/testharness.js"></script> | | 9 | +<script src="/resources/testharnessreport.js"></script> | | 10 | +<script src="resources/timing-attack.js"></script> | | 11 | +<script> | | 12 | +run_test(/*isolated=*/true); | | 13 | +</script> | | 14 | +</head> | | 15 | +<body> | | 16 | +<h1>Description</h1> | | 17 | +<p>The recommended minimum resolution of the Performance interface should be set to 5 microseconds.</p> | | 18 | + | | 19 | +<div id="log"></div> | | 20 | + | | 21 | +</body> | | 22 | +</html> |
Collapse file Copy file name to clipboard +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Cross-Origin-Embedder-Policy: require-corp | | 2 | +Cross-Origin-Opener-Policy: same-origin |
Collapse file Copy file name to clipboard +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// META: script=/resources/idlharness-shadowrealm.js | | 2 | +idl_test_shadowrealm(["hr-time"], ["html", "dom"]); |
Collapse file Copy file name to clipboard +33Lines changed: 33 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!doctype html> | | 2 | +<html> | | 3 | +<head> | | 4 | +<script src="/resources/testharness.js"></script> | | 5 | +<script src="/resources/testharnessreport.js"></script> | | 6 | +</head> | | 7 | +<body> | | 8 | +<script> | | 9 | + function busyWait(millis) { | | 10 | + const start = performance.now(); | | 11 | + while (performance.now() < start + millis) {} | | 12 | + } | | 13 | + promise_test(async t => { | | 14 | + const delay = 3000; | | 15 | + const iframe = document.createElement('iframe'); | | 16 | + iframe.src = './resources/now_frame.html'; | | 17 | + document.body.appendChild(iframe); | | 18 | + await new Promise(resolve => iframe.addEventListener('load', resolve)); | | 19 | + iframe.contentWindow.addEventListener('beforeunload', () => { | | 20 | + busyWait(delay); | | 21 | + }); | | 22 | + iframe.src = './resources/post.html'; | | 23 | + await new Promise(resolve => this.addEventListener('message', ({data}) => { | | 24 | + if (data === 'done') | | 25 | + resolve(); | | 26 | + })); | | 27 | + | | 28 | + const entry = iframe.contentWindow.performance.getEntriesByType('navigation')[0]; | | 29 | + assert_less_than(entry.fetchStart, delay); | | 30 | + }, 'timeOrigin should be set after beforeunload'); | | 31 | +</script> | | 32 | +</body> | | 33 | +</html> |
Collapse file Copy file name to clipboard +30Lines changed: 30 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +const run_test = isolated => { | | 2 | + // Multiplier to convert the clamped timestamps to microseconds. | | 3 | + const multiplier = 1000; | | 4 | + const windowOrigin = performance.timeOrigin; | | 5 | + // Clamp to at least 5 microseconds in isolated contexts and at least 100 in | | 6 | + // non-isolated ones. | | 7 | + const resolution = isolated ? 5 : 100; | | 8 | + | | 9 | + const create_worker = () => { | | 10 | + return new Promise(resolve => { | | 11 | + const workerScript = 'postMessage({timeOrigin: performance.timeOrigin})'; | | 12 | + const blob = new Blob([workerScript]); | | 13 | + const worker = new Worker(URL.createObjectURL(blob)); | | 14 | + worker.addEventListener('message', event => { | | 15 | + resolve(event.data.timeOrigin); | | 16 | + }); | | 17 | + }); | | 18 | + }; | | 19 | + promise_test(async t => { | | 20 | + assert_equals(self.crossOriginIsolated, isolated, | | 21 | + "crossOriginIsolated is properly set"); | | 22 | + let prev = windowOrigin; | | 23 | + let current; | | 24 | + for (let i = 1; i < 100; ++i) { | | 25 | + current = await create_worker(); | | 26 | + assert_true(current === prev || current - prev > resolution / 1000); | | 27 | + prev = current; | | 28 | + } | | 29 | + }, 'timeOrigins are clamped.'); | | 30 | +}; |
Collapse file Copy file name to clipboard +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE HTML> | | 2 | +<script> | | 3 | + window.parent.postMessage('done'); | | 4 | +</script> |
|