tor-browser

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

first-input-interactionid-tap.html (2350B)


      1 <!DOCTYPE html>
      2 <html>
      3 <meta charset=utf-8 />
      4 <title>First Input: interactionId-tap.</title>
      5 <button id='testButtonId'>Tap 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/testdriver-actions.js></script>
     11 <script src=resources/event-timing-test-utils.js></script>
     12 
     13 <script>
     14  let firstInputInteractionId = 0;
     15  let eventTimingPointerDownInteractionId = 0;
     16  let hasFirstInputEntry = false;
     17  let hasEventTimingPointerDownEntry = false;
     18 
     19  promise_test(async t => {
     20    assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
     21 
     22    const callback = (entryList) => {
     23      entryList.getEntries().forEach(entry => {
     24        switch (entry.entryType) {
     25          case 'first-input': {
     26            firstInputInteractionId = entry.interactionId;
     27            hasFirstInputEntry = true;
     28            break;
     29          }
     30          case 'event': {
     31            if ('pointerdown' == entry.name) {
     32              eventTimingPointerDownInteractionId = entry.interactionId;
     33              hasEventTimingPointerDownEntry = true;
     34            }
     35            break;
     36          }
     37        }
     38      });
     39    };
     40    const readyToResolve = () => {
     41      return hasFirstInputEntry && hasEventTimingPointerDownEntry;
     42    }
     43    const observerPromise = createPerformanceObserverPromise(['event', 'first-input'], callback, readyToResolve);
     44    await interactAndObserve('tap', document.getElementById('testButtonId'), observerPromise);
     45 
     46    assert_greater_than(firstInputInteractionId, 0, 'The first input entry should have a non-trivial interactionId');
     47    assert_equals(firstInputInteractionId, eventTimingPointerDownInteractionId, 'The first input entry should have the same interactionId as the event timing pointerdown entry');
     48    assert_equals(firstInputInteractionId.target, eventTimingPointerDownInteractionId.target, 'The first input entry should have the same target as the event timing pointerdown entry');
     49    assert_not_equals(firstInputInteractionId.target, null, 'The first input entry should have a non-null target');
     50 
     51  }, "The interactionId of the first input entry should match the same pointerdown entry of event timing when tap.");
     52 </script>
     53 
     54 </html>