diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/timing-entrytypes-registry | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/timing-entrytypes-registry')
4 files changed, 92 insertions, 0 deletions
diff --git a/testing/web-platform/tests/timing-entrytypes-registry/META.yml b/testing/web-platform/tests/timing-entrytypes-registry/META.yml new file mode 100644 index 0000000000..85b7e0ec16 --- /dev/null +++ b/testing/web-platform/tests/timing-entrytypes-registry/META.yml @@ -0,0 +1,5 @@ +spec: https://w3c.github.io/timing-entrytypes-registry/ +suggested_reviewers: + - plehegar + - igrigorik + - yoavweiss diff --git a/testing/web-platform/tests/timing-entrytypes-registry/registry.any.js b/testing/web-platform/tests/timing-entrytypes-registry/registry.any.js new file mode 100644 index 0000000000..4db249b16b --- /dev/null +++ b/testing/web-platform/tests/timing-entrytypes-registry/registry.any.js @@ -0,0 +1,25 @@ +// META: script=resources/utils.js + +test(() => { + assert_true(!!self.PerformanceObserver, "PerformanceObserver"); + assert_true(!!self.PerformanceObserver.supportedEntryTypes, + "PerformanceObserver.supportedEntryTypes"); +}, "PerformanceObserver.supportedEntryTypes exists"); + +// UPDATE HERE if new entry +[ + [ "mark", "PerformanceMark" ], + [ "measure", "PerformanceMeasure" ], + [ "resource", "PerformanceResourceTiming" ], +].forEach(test_support); + +// UPDATE BELOW to ensure the entry gets created + +// mark +self.performance.mark('mymark'); + +// measure +self.performance.measure('mymeasure'); + +// resource +fetch(self.location.href + "?" + Math.random()); diff --git a/testing/web-platform/tests/timing-entrytypes-registry/registry.window.js b/testing/web-platform/tests/timing-entrytypes-registry/registry.window.js new file mode 100644 index 0000000000..21ef2230e9 --- /dev/null +++ b/testing/web-platform/tests/timing-entrytypes-registry/registry.window.js @@ -0,0 +1,33 @@ +// META: script=resources/utils.js + +test(() => { + assert_true(!!self.PerformanceObserver, "PerformanceObserver"); + assert_true(!!self.PerformanceObserver.supportedEntryTypes, + "PerformanceObserver.supportedEntryTypes"); +}, "PerformanceObserver.supportedEntryTypes exists"); + +// UPDATE HERE if new entry +[ + [ "navigation", "PerformanceNavigationTiming" ], + [ "paint", "PerformancePaintTiming" ], + [ "longtask", "PerformanceLongTaskTiming" ], +].forEach(test_support); + +// UPDATE BELOW to ensure the entry gets created + +// paint +if (self.document) document.head.parentNode.appendChild(document.createTextNode('text inserted on purpose')); + +// longtask +function syncWait(waitDuration) { + if (waitDuration <= 0) + return; + + const startTime = performance.now(); + let unused = ''; + for (let i = 0; i < 10000; i++) + unused += '' + Math.random(); + + return syncWait(waitDuration - (performance.now() - startTime)); +} +syncWait(50); diff --git a/testing/web-platform/tests/timing-entrytypes-registry/resources/utils.js b/testing/web-platform/tests/timing-entrytypes-registry/resources/utils.js new file mode 100644 index 0000000000..0ec96057ad --- /dev/null +++ b/testing/web-platform/tests/timing-entrytypes-registry/resources/utils.js @@ -0,0 +1,29 @@ +const STEPS = {}; + +const types = (self.PerformanceObserver + && self.PerformanceObserver.supportedEntryTypes)? + self.PerformanceObserver.supportedEntryTypes + : undefined; + +if (types) { + // we observe everything as soon as possible + new PerformanceObserver(function (list, observer) { + for (const entry of list.getEntries()) + if (STEPS[entry.entryType]) STEPS[entry.entryType](entry); + }).observe({entryTypes: self.PerformanceObserver.supportedEntryTypes}); +} + +function test_support(def) { + if (!types || !types.includes(def[0])) { + return; + } + const desc = `'${def[0]}' entries should be observable`; + const t = async_test(desc); + + STEPS[def[0]] = (entry) => { + t.step(() => assert_equals(Object.prototype.toString.call(entry), + `[object ${def[1]}]`, + `Class name of entry should be ${def[1]}.`)); + t.done(); + } +} |