blob: bcd4079256d09d613684edaf802f026f674f9078 [file] [log] [blame]
Aoyuan Zuo5bebbfb2022-06-07 22:08:031<!DOCTYPE html>
2<html>
3<meta charset=utf-8 />
Blink WPT Bot64af02f2022-07-11 13:32:074<title>First Input: interactionId-click.</title>
5<button id='testButtonId'>Click me</button>
Aoyuan Zuo5bebbfb2022-06-07 22:08:036<script src=/resources/testharness.js></script>
7<script src=/resources/testharnessreport.js></script>
8<script src=/resources/testdriver.js></script>
Aoyuan Zuo5bebbfb2022-06-07 22:08:039<script src=/resources/testdriver-vendor.js></script>
10<script src=resources/event-timing-test-utils.js></script>
11
12<script>
13 let firstInputInteractionId = 0;
14 let eventTimingPointerDownInteractionId = 0;
15 let hasFirstInputEntry = false;
16 let hasEventTimingPointerDownEntry = false;
17
Blink WPT Bot7aa98ce2022-09-21 18:08:3118 promise_test(async t => {
Aoyuan Zuo5bebbfb2022-06-07 22:08:0319 assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
20
Blink WPT Bot7aa98ce2022-09-21 18:08:3121 const callback = (entryList) => {
Aoyuan Zuo5bebbfb2022-06-07 22:08:0322 entryList.getEntries().forEach(entry => {
23 switch (entry.entryType) {
Blink WPT Bot7aa98ce2022-09-21 18:08:3124 case 'first-input': {
Aoyuan Zuo5bebbfb2022-06-07 22:08:0325 firstInputInteractionId = entry.interactionId;
26 hasFirstInputEntry = true;
27 break;
28 }
Blink WPT Bot7aa98ce2022-09-21 18:08:3129 case 'event': {
Aoyuan Zuo5bebbfb2022-06-07 22:08:0330 if ('pointerdown' == entry.name) {
31 eventTimingPointerDownInteractionId = entry.interactionId;
32 hasEventTimingPointerDownEntry = true;
33 }
34 break;
35 }
36 }
Blink WPT Bot7aa98ce2022-09-21 18:08:3137 });
38 };
39 const readyToResolve = () => {
40 return hasFirstInputEntry && hasEventTimingPointerDownEntry;
41 }
42 const observerPromise = createPerformanceObserverPromise(['event', 'first-input'], callback, readyToResolve);
43 await interactAndObserve('click', document.getElementById('testButtonId'), observerPromise);
Aoyuan Zuo5bebbfb2022-06-07 22:08:0344
Blink WPT Bot7aa98ce2022-09-21 18:08:3145 assert_greater_than(firstInputInteractionId, 0, 'The first input entry should have a non-trivial interactionId');
46 assert_equals(firstInputInteractionId, eventTimingPointerDownInteractionId, 'The first input entry should have the same interactionId as the event timing pointerdown entry');
Aoyuan Zuo5bebbfb2022-06-07 22:08:0347
Blink WPT Bot64af02f2022-07-11 13:32:0748 }, "The interactionId of the first input entry should match the same pointerdown entry of event timing when click.");
Aoyuan Zuo5bebbfb2022-06-07 22:08:0349</script>
50
51</html>