summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/event-timing/buffered-and-duration-threshold.html
diff options
context:
space:
mode:
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.html44
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..5f8d27c034
--- /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 clickAndBlockMain('myDiv', { duration: 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 clickAndBlockMain('myDiv', { duration: 30 } );
+ });
+}, "PerformanceObserver buffering independent of durationThreshold");
+</script>
+</html>