Skip to content

Commit

Permalink
test: update hr-time wpt
Browse files Browse the repository at this point in the history
  • Loading branch information
RedYetiDev committed Sep 30, 2024
1 parent 317d245 commit 328910a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Last update:
- encoding: https://github.com/web-platform-tests/wpt/tree/1ac8deee08/encoding
- fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources
- FileAPI: https://github.com/web-platform-tests/wpt/tree/cceaf3628d/FileAPI
- hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time
- hr-time: https://github.com/web-platform-tests/wpt/tree/614e81711c/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 Down
36 changes: 36 additions & 0 deletions test/fixtures/wpt/hr-time/raf-coarsened-time.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
/* Coarsen to 5 microseconds or coarser */
const COARSE_RESOLUTION = 0.005;

const CUSTOM_TIMELINE_DELTA = 0.002;
const FLOATING_POINT_ERROR_EPSILON = 0.01;

// Note that this test would fail if the platform introduces a jitter.
// It is recommended that platforms that implement jitter run this test
// with a flag that turns jitter off, if possible.

const customTimeline = new DocumentTimeline({originTime: CUSTOM_TIMELINE_DELTA});
promise_test(async t => {
for (let i = 0; i < 32; ++i) {
const timestamp = await new Promise(resolve => requestAnimationFrame(ts => resolve(ts)));
const coarse_timestamp = Math.round(timestamp / COARSE_RESOLUTION) * COARSE_RESOLUTION;
assert_approx_equals(timestamp, coarse_timestamp, FLOATING_POINT_ERROR_EPSILON,
"timestamp should be coarsened");
assert_approx_equals(timestamp, document.timeline.currentTime, FLOATING_POINT_ERROR_EPSILON,
"document.timeline.currentTimeline should be the same as the rAF callback");
assert_approx_equals(customTimeline.currentTime + CUSTOM_TIMELINE_DELTA,
timestamp, FLOATING_POINT_ERROR_EPSILON,
"originTime for custom timeline should not be coarsened");
}
});
</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
2 changes: 1 addition & 1 deletion test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"path": "FileAPI"
},
"hr-time": {
"commit": "34cafd797e58dad280d20040eee012d49ccfa91f",
"commit": "614e81711cdf3f3552d8454bd447cd2f0859ae90",
"path": "hr-time"
},
"html/webappapis/atob": {
Expand Down

0 comments on commit 328910a

Please sign in to comment.