summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/event-timing/click-timing.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/click-timing.html
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.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/click-timing.html')
-rw-r--r--testing/web-platform/tests/event-timing/click-timing.html62
1 files changed, 62 insertions, 0 deletions
diff --git a/testing/web-platform/tests/event-timing/click-timing.html b/testing/web-platform/tests/event-timing/click-timing.html
new file mode 100644
index 0000000000..24bad0aedc
--- /dev/null
+++ b/testing/web-platform/tests/event-timing/click-timing.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8 />
+<title>Event Timing: compare timing of two long clicks
+</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>
+ /* Timeline:
+ Observer starts
+ Long click 1
+ Long click 2
+ Once two clicks have been received by observer, compare the timestamps.
+ */
+ let timeBeforeFirstClick;
+ let timeAfterFirstClick;
+ let timeAfterSecondClick;
+ let observedEntries = [];
+ async_test(function(t) {
+ assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
+ new PerformanceObserver(t.step_func(entryList => {
+ observedEntries = observedEntries.concat(entryList.getEntries().filter(
+ entry => entry.name === 'pointerdown'));
+ if (observedEntries.length < 2)
+ return;
+
+ assert_not_equals(timeBeforeFirstClick, undefined);
+ assert_not_equals(timeAfterFirstClick, undefined);
+ assert_not_equals(timeAfterSecondClick, undefined);
+ // First click.
+ verifyClickEvent(observedEntries[0], 'button');
+ assert_between_exclusive(observedEntries[0].processingStart,
+ timeBeforeFirstClick,
+ timeAfterFirstClick,
+ "First click's processingStart");
+ assert_greater_than(timeAfterFirstClick, observedEntries[0].startTime,
+ "timeAfterFirstClick should be later than first click's start time.");
+
+ // Second click.
+ verifyClickEvent(observedEntries[1], 'button');
+ assert_between_exclusive(observedEntries[1].processingStart,
+ timeAfterFirstClick,
+ timeAfterSecondClick,
+ "Second click's processingStart");
+ assert_greater_than(timeAfterSecondClick, observedEntries[1].startTime,
+ "timeAfterSecondClick should be later than second click's start time.");
+ t.done();
+ })).observe({type: 'event'});
+ timeBeforeFirstClick = performance.now();
+ clickAndBlockMain('button').then( () => {
+ timeAfterFirstClick = performance.now();
+ clickAndBlockMain('button').then(() => {
+ timeAfterSecondClick = performance.now();
+ })
+ });
+ }, "Event Timing: compare click timings.");
+</script>
+</html>