diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/event-timing/buffered-and-duration-threshold.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/event-timing/buffered-and-duration-threshold.html')
-rw-r--r-- | testing/web-platform/tests/event-timing/buffered-and-duration-threshold.html | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/testing/web-platform/tests/event-timing/buffered-and-duration-threshold.html b/testing/web-platform/tests/event-timing/buffered-and-duration-threshold.html new file mode 100644 index 0000000000..4a7a63f59a --- /dev/null +++ b/testing/web-platform/tests/event-timing/buffered-and-duration-threshold.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<html> +<meta charset=utf-8 /> +<title>Event Timing: PerformanceObserver with buffered flag and durationThreshold</title> +<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> +<div id='myDiv'>Click me</div> +<script> +promise_test(async t => { + assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.'); + // Add a PerformanceObserver and observe with a durationThreshold of 30 and buffered flag. + return new Promise(async resolve1 => { + // Add a slow click event and make sure it's dispatched to observers. + await new Promise(async resolve2 => { + // Observer to await until event entry is dispatched. + new PerformanceObserver(() => { + resolve2(); + }).observe({type: "event", durationThreshold: 16}); + await clickOnElementAndDelay('myDiv', 30); + }); + const afterFirstClick = performance.now(); + new PerformanceObserver(t.step_func(list => { + const pointerDowns = list.getEntriesByName('pointerdown'); + pointerDowns.forEach(entry => { + if (entry.processingStart < afterFirstClick) { + // It is possible that the first event gets a slow duration and hence gets buffered. + // In this case the minDuration must be at least 104, otherwise it shouldn't have been + // buffered. + verifyClickEvent(entry, 'myDiv', true /* isFirst */); + } else { + verifyClickEvent(pointerDowns[0], 'myDiv', false /* isFirst */, 16 /* minDuration*/); + resolve1(); + } + }); + })).observe({type: 'event', durationThreshold: 16, buffered: true}); + // This should be the only click observed since the other one would not be buffered. + await clickOnElementAndDelay('myDiv', 30); + }); +}, "PerformanceObserver buffering independent of durationThreshold"); +</script> +</html> |