GeezerVison is showing github.com — test: update user-timing web-platform tests · nodejs/node@83cfc67
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 |
|---|
@@ -28,7 +28,7 @@ Last update: | 28 | 28 | - resources: https://github.com/web-platform-tests/wpt/tree/919874f84f/resources | 29 | 29 | - streams: https://github.com/web-platform-tests/wpt/tree/51750bc8d7/streams | 30 | 30 | - url: https://github.com/web-platform-tests/wpt/tree/c4726447f3/url | 31 | | -- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing | | 31 | +- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing | 32 | 32 | - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi | 33 | 33 | - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi | 34 | 34 | - WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/17b7ca10fd/WebCryptoAPI | |
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(["user-timing"], ["hr-time", "performance-timeline", "dom"]); |
Collapse file Copy file name to clipboard +47-12Lines changed: 47 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -test(function() { | 2 | | - assert_throws_js(TypeError, function() { self.performance.mark("mark1", 123); }, "Number passed as a dict argument should cause type-error.") | 3 | | -}, "Number should be rejected as the mark-options.") | | 1 | +// If you're testing an API that constructs a PerformanceMark, add your test here. | | 2 | +// See the for loop below for details. | | 3 | +const markConstructionTests = [ | | 4 | + { | | 5 | + testName: "Number should be rejected as the mark-options.", | | 6 | + testFunction: function(newMarkFunction) { | | 7 | + assert_throws_js(TypeError, function() { newMarkFunction("mark1", 123); }, "Number passed as a dict argument should cause type-error."); | | 8 | + }, | | 9 | + }, | 4 | 10 |
| 5 | | -test(function() { | 6 | | - assert_throws_js(TypeError, function() { self.performance.mark("mark1", NaN); }, "NaN passed as a dict argument should cause type-error.") | 7 | | -}, "NaN should be rejected as the mark-options.") | | 11 | + { | | 12 | + testName: "NaN should be rejected as the mark-options.", | | 13 | + testFunction: function(newMarkFunction) { | | 14 | + assert_throws_js(TypeError, function() { newMarkFunction("mark1", NaN); }, "NaN passed as a dict argument should cause type-error."); | | 15 | + }, | | 16 | + }, | 8 | 17 |
| 9 | | -test(function() { | 10 | | - assert_throws_js(TypeError, function() { self.performance.mark("mark1", Infinity); }, "Infinity passed as a dict argument should cause type-error.") | 11 | | -}, "Infinity should be rejected as the mark-options.") | | 18 | + { | | 19 | + testName: "Infinity should be rejected as the mark-options.", | | 20 | + testFunction: function(newMarkFunction) { | | 21 | + assert_throws_js(TypeError, function() { newMarkFunction("mark1", Infinity); }, "Infinity passed as a dict argument should cause type-error."); | | 22 | + }, | | 23 | + }, | 12 | 24 |
| 13 | | -test(function() { | 14 | | - assert_throws_js(TypeError, function() { self.performance.mark("mark1", "string"); }, "String passed as a dict argument should cause type-error.") | 15 | | -}, "String should be rejected as the mark-options.") | | 25 | + { | | 26 | + testName: "String should be rejected as the mark-options.", | | 27 | + testFunction: function(newMarkFunction) { | | 28 | + assert_throws_js(TypeError, function() { newMarkFunction("mark1", "string"); }, "String passed as a dict argument should cause type-error.") | | 29 | + }, | | 30 | + }, | | 31 | + | | 32 | + { | | 33 | + testName: "Negative startTime in mark-options should be rejected", | | 34 | + testFunction: function(newMarkFunction) { | | 35 | + assert_throws_js(TypeError, function() { newMarkFunction("mark1", {startTime: -1}); }, "Negative startTime should cause type-error.") | | 36 | + }, | | 37 | + }, | | 38 | +]; | | 39 | + | | 40 | +// There are multiple function calls that can construct a mark using the same arguments so we run | | 41 | +// each test on each construction method here, avoiding duplication. | | 42 | +for (let testInfo of markConstructionTests) { | | 43 | + test(function() { | | 44 | + testInfo.testFunction(self.performance.mark); | | 45 | + }, `[performance.mark]: ${testInfo.testName}`); | | 46 | + | | 47 | + test(function() { | | 48 | + testInfo.testFunction((markName, obj) => new PerformanceMark(markName, obj)); | | 49 | + }, `[new PerformanceMark]: ${testInfo.testName}`); | | 50 | +} |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/user-timing/measure-l3.any.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,12 +17,12 @@ test(function() { | 17 | 17 | performance.clearMarks(); | 18 | 18 | performance.clearMeasures(); | 19 | 19 | const markEntry = performance.mark("mark", {startTime: 123}); | 20 | | - const endMin = performance.now(); | | 20 | + const endMin = Number(performance.now().toFixed(2)); | 21 | 21 | const measureEntry = performance.measure("A", "mark", undefined); | 22 | | - const endMax = performance.now(); | | 22 | + const endMax = Number(performance.now().toFixed(2)); | 23 | 23 | assert_equals(measureEntry.startTime, markEntry.startTime); | 24 | | - assert_greater_than_equal(endTime(measureEntry), endMin); | 25 | | - assert_greater_than_equal(endMax, endTime(measureEntry)); | | 24 | + assert_greater_than_equal(Number(endTime(measureEntry).toFixed(2)), endMin); | | 25 | + assert_greater_than_equal(endMax, Number(endTime(measureEntry).toFixed(2))); | 26 | 26 | }, "When the start mark is given and the end is unprovided, the start time of the measure entry should be the start mark's time, the end should be now."); | 27 | 27 |
| 28 | 28 | test(function() { | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/user-timing/measure_associated_with_navigation_timing.html +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 34 | 34 | test_greater_than(0, context.getEntriesByName('negativeValue', 'measure')[0].duration, 'Measure of current mark to navigationStart should be negative value.'); | 35 | 35 | test_equals(context.getEntriesByName('loadTime', 'measure')[0].duration + context.getEntriesByName('loadEventEnd2a', 'measure')[0].duration, context.getEntriesByName('nav2a', 'measure')[0].duration, 'loadTime plus loadEventEnd to a mark "a" should equal to navigationStart to "a".'); | 36 | 36 |
| | 37 | + // We later assert that time has passed between setting one set of marks and another set. | | 38 | + // However, this assertion will fail if the test executes fast enough such that the marks occur | | 39 | + // at the same clock time. This is more likely in browsers such as Firefox that reduce the | | 40 | + // precision of the clock exposed through this API to mitigate timing attacks. To mitigate the | | 41 | + // test failure, we sleep. Firefox may round timestamps to the nearest millisecond in either | | 42 | + // direction - e.g. 10ms & 11.999ms may both round to 11ms - so we need to sleep at least 2ms to | | 43 | + // avoid test failures. To be safe, we sleep 3ms. | | 44 | + sleep_milliseconds(3); | | 45 | + | 37 | 46 | // Following cases test for scenarios that measure names are tied twice. | 38 | 47 | mark_names.forEach(function(name) { | 39 | 48 | context.mark(name); | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/user-timing/performance-measure-invalid.worker.js +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,4 +6,11 @@ test(() => { | 6 | 6 | }); | 7 | 7 | }, "When converting 'navigationStart' to a timestamp, the global object has to be a Window object."); | 8 | 8 |
| | 9 | +test(() => { | | 10 | + assert_throws_js(TypeError, () => { | | 11 | + performance.mark('navigationStart'); | | 12 | + performance.measure('name', 'navigationStart', 'navigationStart'); | | 13 | + }); | | 14 | +}, "When converting 'navigationStart' to a timestamp and a mark named 'navigationStart' exists, the global object has to be a Window object."); | | 15 | + | 9 | 16 | done(); |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/user-timing/resources/webperftestharness.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -110,12 +110,12 @@ function sleep_milliseconds(n) | 110 | 110 |
| 111 | 111 | function test_greater_than(value, greater_than, msg, properties) | 112 | 112 | { | 113 | | - wp_test(function () { assert_true(value > greater_than, msg); }, msg, properties); | | 113 | + wp_test(function () { assert_greater_than(value, greater_than, msg); }, msg, properties); | 114 | 114 | } | 115 | 115 |
| 116 | 116 | function test_greater_or_equals(value, greater_than, msg, properties) | 117 | 117 | { | 118 | | - wp_test(function () { assert_true(value >= greater_than, msg); }, msg, properties); | | 118 | + wp_test(function () { assert_greater_than_equal(value, greater_than, msg); }, msg, properties); | 119 | 119 | } | 120 | 120 |
| 121 | 121 | function test_not_equals(value, notequals, msg, properties) | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/user-timing/structured-serialize-detail.any.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,6 +10,7 @@ test(function() { | 10 | 10 | performance.clearMarks(); | 11 | 11 | const detail = { randomInfo: 123 } | 12 | 12 | const markEntry = performance.mark("A", { detail }); | | 13 | + assert_equals(markEntry.detail.randomInfo, detail.randomInfo); | 13 | 14 | assert_not_equals(markEntry.detail, detail); | 14 | 15 | }, "The detail property in the mark method should be structured-clone."); | 15 | 16 |
| @@ -31,6 +32,7 @@ test(function() { | 31 | 32 | performance.clearMeasures(); | 32 | 33 | const detail = { randomInfo: 123 } | 33 | 34 | const measureEntry = performance.measure("A", { start: 0, detail }); | | 35 | + assert_equals(measureEntry.detail.randomInfo, detail.randomInfo); | 34 | 36 | assert_not_equals(measureEntry.detail, detail); | 35 | 37 | }, "The detail property in the measure method should be structured-clone."); | 36 | 38 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/versions.json +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 72 | 72 | "path": "url" | 73 | 73 | }, | 74 | 74 | "user-timing": { | 75 | | - "commit": "df24fb604e2d40528ac1d1b5dd970e32fc5c2978", | | 75 | + "commit": "5ae85bf8267ac617833dc013dee9774c9e2a18b7", | 76 | 76 | "path": "user-timing" | 77 | 77 | }, | 78 | 78 | "wasm/jsapi": { | |
|