summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/event-timing/buffered-flag.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/event-timing/buffered-flag.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/event-timing/buffered-flag.html')
-rw-r--r--testing/web-platform/tests/event-timing/buffered-flag.html46
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/web-platform/tests/event-timing/buffered-flag.html b/testing/web-platform/tests/event-timing/buffered-flag.html
new file mode 100644
index 0000000000..7ee152be93
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/buffered-flag.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: PerformanceObserver sees entries with buffered flag</title>
+<button id='button'>Generate a 'click' event</button>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=/resources/testdriver.js></script>
+<script src=/resources/testdriver-vendor.js></script>
+<script src=resources/event-timing-test-utils.js></script>
+<script>
+ let firstInputSeen = false;
+ let eventSeen = false;
+ async_test(t => {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ const validateEntry = t.step_func(entry => {
+ if (entry.entryType === 'first-input')
+ firstInputSeen = true;
+ else if (entry.entryType === 'event')
+ eventSeen = true;
+ else
+ assert_unreached('Should only observe Event Timing entries!');
+ });
+ // First observer creates second in callback to ensure the entry has been dispatched by the time
+ // the second observer begins observing.
+ new PerformanceObserver((list, obs) => {
+ list.getEntries().forEach(validateEntry);
+ if (!firstInputSeen || !eventSeen)
+ return;
+
+ obs.disconnect();
+ firstInputSeen = false;
+ eventSeen = false;
+ // Second observer requires 'buffered: true' to see entries.
+ const bufferedObserver = new PerformanceObserver(entryList => {
+ entryList.getEntries().forEach(validateEntry);
+ if (firstInputSeen && eventSeen)
+ t.done();
+ });
+ bufferedObserver.observe({type: "event", buffered: true});
+ bufferedObserver.observe({type: 'first-input', buffered: true});
+ }).observe({entryTypes: ['event', 'first-input']});
+ clickAndBlockMain('button');
+ }, "PerformanceObserver with buffered flag sees previous Event Timing entries");
+</script>
+</html>