GeezerVison is showing github.com — test: add hr-time Web platform tests · nodejs/node@1d2c81f
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 +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,7 @@ Last update: | 17 | 17 | - interfaces: https://github.com/web-platform-tests/wpt/tree/712c9f275e/interfaces | 18 | 18 | - html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/0c3bed38df/html/webappapis/microtask-queuing | 19 | 19 | - html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/ddfe9c089b/html/webappapis/timers | | 20 | +- hr-time: https://github.com/web-platform-tests/wpt/tree/a5d1774ecf/hr-time | 20 | 21 |
| 21 | 22 | [Web Platform Tests]: https://github.com/web-platform-tests/wpt | 22 | 23 | [`git node wpt`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-wpt |
Collapse file Copy file name to clipboard +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +spec: https://w3c.github.io/hr-time/ | | 2 | +suggested_reviewers: | | 3 | + - plehegar | | 4 | + - igrigorik |
Collapse file Copy file name to clipboard +28Lines changed: 28 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +test(function() { | | 2 | + assert_true((self.performance !== undefined), "self.performance exists"); | | 3 | + assert_equals(typeof self.performance, "object", "self.performance is an object"); | | 4 | + assert_equals((typeof self.performance.now), "function", "self.performance.now() is a function"); | | 5 | + assert_equals(typeof self.performance.now(), "number", "self.performance.now() returns a number"); | | 6 | +}, "self.performance.now() is a function that returns a number"); | | 7 | + | | 8 | +test(function() { | | 9 | + assert_true(self.performance.now() > 0); | | 10 | +}, "self.performance.now() returns a positive number"); | | 11 | + | | 12 | +test(function() { | | 13 | + var now1 = self.performance.now(); | | 14 | + var now2 = self.performance.now(); | | 15 | + assert_true((now2-now1) >= 0); | | 16 | + }, "self.performance.now() difference is not negative"); | | 17 | + | | 18 | +async_test(function() { | | 19 | + // Check whether the performance.now() method is close to Date() within 30ms (due to inaccuracies) | | 20 | + var initial_hrt = self.performance.now(); | | 21 | + var initial_date = Date.now(); | | 22 | + this.step_timeout(function() { | | 23 | + var final_hrt = self.performance.now(); | | 24 | + var final_date = Date.now(); | | 25 | + assert_approx_equals(final_hrt - initial_hrt, final_date - initial_date, 30, 'High resolution time value increased by approximately the same amount as time from date object'); | | 26 | + this.done(); | | 27 | + }, 2000); | | 28 | +}, 'High resolution time has approximately the right relative magnitude'); |
Collapse file Copy file name to clipboard +23Lines changed: 23 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// META: global=window,worker | | 2 | +// META: script=/resources/WebIDLParser.js | | 3 | +// META: script=/resources/idlharness.js | | 4 | +// META: timeout=long | | 5 | + | | 6 | +'use strict'; | | 7 | + | | 8 | +// https://w3c.github.io/hr-time/ | | 9 | + | | 10 | +idl_test( | | 11 | + ['hr-time'], | | 12 | + ['html', 'dom'], | | 13 | + async idl_array => { | | 14 | + if (self.GLOBAL.isWorker()) { | | 15 | + idl_array.add_objects({ WorkerGlobalScope: ['self'] }); | | 16 | + } else { | | 17 | + idl_array.add_objects({ Window: ['self'] }); | | 18 | + } | | 19 | + idl_array.add_objects({ | | 20 | + Performance: ['performance'], | | 21 | + }); | | 22 | + } | | 23 | +); |
Collapse file Copy file name to clipboard +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// The time values returned when calling the now method MUST be monotonically increasing and not subject to system clock adjustments or system clock skew. | | 2 | +test(function() { | | 3 | + assert_true(self.performance.now() > 0, "self.performance.now() returns positive numbers"); | | 4 | +}, "self.performance.now() returns a positive number"); | | 5 | + | | 6 | +// The difference between any two chronologically recorded time values returned from the now method MUST never be negative. | | 7 | +test(function() { | | 8 | + var now1 = self.performance.now(); | | 9 | + var now2 = self.performance.now(); | | 10 | + assert_true((now2-now1) >= 0, "self.performance.now() difference is not negative"); | | 11 | + }, | | 12 | + "self.performance.now() difference is not negative" | | 13 | +); |
Collapse file Copy file name to clipboard +76Lines changed: 76 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 | + | | 10 | +test(() => { | | 11 | + // Check Performance attributes. | | 12 | + assert_equals(typeof(performance.toJSON), 'function'); | | 13 | + const json = performance.toJSON(); | | 14 | + assert_equals(typeof(json), 'object'); | | 15 | + assert_equals(json.timeOrigin, performance.timeOrigin, | | 16 | + 'performance.toJSON().timeOrigin should match performance.timeOrigin'); | | 17 | + | | 18 | + // Check PerformanceTiming toJSON. | | 19 | + const jsonTiming = json.timing; | | 20 | + const timing = performance.timing; | | 21 | + assert_equals(typeof(timing.toJSON), 'function'); | | 22 | + const timingJSON = timing.toJSON(); | | 23 | + assert_equals(typeof(timingJSON), 'object'); | | 24 | + // Check PerformanceTiming attributes, from both: | | 25 | + // 1) |jsonTiming| from Performance. | | 26 | + // 2) |timingJSON| from PerformanceTiming. | | 27 | + const performanceTimingKeys = [ | | 28 | + 'navigationStart', | | 29 | + 'unloadEventStart', | | 30 | + 'unloadEventEnd', | | 31 | + 'redirectStart', | | 32 | + 'redirectEnd', | | 33 | + 'fetchStart', | | 34 | + 'domainLookupStart', | | 35 | + 'domainLookupEnd', | | 36 | + 'connectStart', | | 37 | + 'connectEnd', | | 38 | + 'secureConnectionStart', | | 39 | + 'requestStart', | | 40 | + 'responseStart', | | 41 | + 'responseEnd', | | 42 | + 'domLoading', | | 43 | + 'domInteractive', | | 44 | + 'domContentLoadedEventStart', | | 45 | + 'domContentLoadedEventEnd', | | 46 | + 'domComplete', | | 47 | + 'loadEventStart', | | 48 | + 'loadEventEnd' | | 49 | + ]; | | 50 | + for (const key of performanceTimingKeys) { | | 51 | + assert_equals(jsonTiming[key], timing[key], | | 52 | + `performance.toJSON().timing.${key} should match performance.timing.${key}`); | | 53 | + assert_equals(timingJSON[key], timing[key], | | 54 | + `performance.timing.toJSON().${key} should match performance.timing.${key}`); | | 55 | + } | | 56 | + | | 57 | + // Check PerformanceNavigation toJSON. | | 58 | + const jsonNavigation = json.navigation; | | 59 | + const navigation = performance.navigation; | | 60 | + assert_equals(typeof(navigation.toJSON), 'function'); | | 61 | + const navigationJSON = navigation.toJSON(); | | 62 | + assert_equals(typeof(navigationJSON), 'object'); | | 63 | + // Check PerformanceNavigation attributes, from both: | | 64 | + // 1) |jsonNavigation| from Performance. | | 65 | + // 2) |navigationJSON| from PerformanceNavigation. | | 66 | + let performanceNavigationKeys = ['type', 'redirectCount']; | | 67 | + for (const key of performanceNavigationKeys) { | | 68 | + assert_equals(jsonNavigation[key], navigation[key], | | 69 | + `performance.toJSON().navigation.${key} should match performance.navigation.${key}`); | | 70 | + assert_equals(navigationJSON[key], navigation[key], | | 71 | + `performance.navigation.toJSON().${key} should match performance.navigation.${key}`); | | 72 | + } | | 73 | +}, 'Test performance.toJSON()'); | | 74 | +</script> | | 75 | +</body> | | 76 | +</html> |
Collapse file Copy file name to clipboard +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE HTML> | | 2 | +<html> | | 3 | + <head> | | 4 | + <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> | | 5 | + <title>window.performance.now frame</title> | | 6 | + <link rel="author" title="Google" href="http://www.google.com/" /> | | 7 | + </head> | | 8 | + <body></body> | | 9 | +</html> |
Collapse file Copy file name to clipboard +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <title>Helper page for ../unload-manual.html</title> | | 5 | +</head> | | 6 | +<body> | | 7 | + <script src="./unload.js"></script> | | 8 | + <script> | | 9 | + setupListeners("a", "./unload-b.html"); | | 10 | + </script> | | 11 | + <button id="proceed">Click me!</button> | | 12 | +</body> | | 13 | +</html> |
Collapse file Copy file name to clipboard +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <title>Helper page for ../unload-manual.html</title> | | 5 | +</head> | | 6 | +<body> | | 7 | + <script src="./unload.js"></script> | | 8 | + <script> | | 9 | + setupListeners("b", "./unload-c.html"); | | 10 | + </script> | | 11 | + <button id="proceed">Click me again!</button> | | 12 | +</body> | | 13 | +</html> |
Collapse file Copy file name to clipboard +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <title>Helper page for ../unload-manual.html</title> | | 5 | +</head> | | 6 | +<body> | | 7 | + <script src="./unload.js"></script> | | 8 | + <script> | | 9 | + setupListeners("c", null); | | 10 | + </script> | | 11 | + <button id="proceed">Click me, one last time!</button> | | 12 | +</body> | | 13 | +</html> |
|