Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ba1915d

Browse filesBrowse files
anonrigdanielleadams
authored andcommitted
test: update hr-time web platform tests
PR-URL: #44100 Reviewed-By: Feng Yu <F3n67u@outlook.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent bcb94aa commit ba1915d
Copy full SHA for ba1915d
Expand file treeCollapse file tree

13 files changed

+170
-38
lines changed
Open diff view settings
Collapse file

‎test/fixtures/wpt/README.md‎

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 numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Last update:
1616
- dom/events: https://github.com/web-platform-tests/wpt/tree/f8821adb28/dom/events
1717
- encoding: https://github.com/web-platform-tests/wpt/tree/c1b24fce6e/encoding
1818
- 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
2020
- html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob
2121
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
2222
- html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/47d3fb280c/html/webappapis/structured-clone
Collapse file
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cross-Origin-Embedder-Policy: require-corp
2+
Cross-Origin-Opener-Policy: same-origin
Collapse file
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cross-Origin-Embedder-Policy: require-corp
2+
Cross-Origin-Opener-Policy: same-origin
Collapse file
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// META: script=/resources/idlharness-shadowrealm.js
2+
idl_test_shadowrealm(["hr-time"], ["html", "dom"]);
Collapse file
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!DOCTYPE HTML>
2+
<script>
3+
window.parent.postMessage('done');
4+
</script>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.