tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

first-input-interactionid-click.html (2001B)


      1 <!DOCTYPE html>
      2 <html>
      3 <meta charset=utf-8 />
      4 <title>First Input: interactionId-click.</title>
      5 <button id='testButtonId'>Click me</button>
      6 <script src=/resources/testharness.js></script>
      7 <script src=/resources/testharnessreport.js></script>
      8 <script src=/resources/testdriver.js></script>
      9 <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 
     18  promise_test(async t => {
     19    assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
     20 
     21    const callback = (entryList) => {
     22      entryList.getEntries().forEach(entry => {
     23        switch (entry.entryType) {
     24          case 'first-input': {
     25            firstInputInteractionId = entry.interactionId;
     26            hasFirstInputEntry = true;
     27            break;
     28          }
     29          case 'event': {
     30            if ('pointerdown' == entry.name) {
     31              eventTimingPointerDownInteractionId = entry.interactionId;
     32              hasEventTimingPointerDownEntry = true;
     33            }
     34            break;
     35          }
     36        }
     37      });
     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);
     44 
     45    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');
     47 
     48  }, "The interactionId of the first input entry should match the same pointerdown entry of event timing when click.");
     49 </script>
     50 
     51 </html>