tor-browser

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

modal-dialog-interrupt-paint.html (1836B)


      1 <!DOCTYPE html>
      2 <html>
      3 <meta charset=utf-8 />
      4 <title>Event Timing: Modal Dialog Interrupt Paint</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-actions.js></script>
     10 <script src=/resources/testdriver-vendor.js></script>
     11 <script src=resources/event-timing-test-utils.js></script>
     12 
     13 <script>
     14  let observedEntries = [];
     15  const map = new Map();
     16  const events = ['click'];
     17  const showModalDialog = () => {
     18    alert();
     19    // Stay busy for a few more ms after dialog closes, to ensure processingEnd
     20    // time is far from startTime + duration
     21    mainThreadBusy(16);
     22  };
     23  document.getElementById('testButtonId').addEventListener("click", showModalDialog);
     24 
     25  promise_test(async t => {
     26    assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
     27 
     28    const callback = (entryList) => { observedEntries = observedEntries.concat(entryList.getEntries().filter(filterAndAddToMap(events, map))); };
     29    const readyToResolve = () => { return observedEntries.length >= 1; };
     30    const observerPromise = createPerformanceObserverPromise(['event'], callback, readyToResolve);
     31 
     32    await interactAndObserve('click', document.getElementById('testButtonId'), observerPromise);
     33 
     34    const clickEntry = observedEntries[0];
     35    assert_less_than(clickEntry.startTime + clickEntry.duration, clickEntry.processingEnd, 'Event duration measurement should stop at the modal dialog showing time, which should be before processingEnd.');
     36    assert_greater_than(clickEntry.interactionId, 0, 'Should have a non-trivial interactionId for click event');
     37  }, "Event Timing: showing modal dialogs is an alternative end point.");
     38 
     39 </script>
     40 
     41 </html>