tor-browser

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

only-observe-firstInput.html (1901B)


      1 <!DOCTYPE html>
      2 <html>
      3 <meta charset=utf-8 />
      4 <title>Event Timing: only observe the first input</title>
      5 <button id='button'>Generate a 'click' event</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 
     11 <script src=resources/event-timing-test-utils.js></script>
     12 
     13 <script>
     14  /* Test:
     15     PerformanceObserver for first-input is registered
     16     Click 1
     17     Click 2
     18     Wait
     19     Expected result:
     20     PerformanceObserver should observe one and only one entry.
     21  */
     22  async_test(function(t) {
     23    assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
     24    let hasObservedFirstInput = false;
     25    new PerformanceObserver(t.step_func((entryList) => {
     26        assert_false(hasObservedFirstInput);
     27        hasObservedFirstInput = true;
     28        const observedEntries = entryList.getEntries().filter(
     29            entry => entry.name === 'pointerdown');
     30        assert_equals(observedEntries.length, 1);
     31        assert_equals(observedEntries[0].entryType, 'first-input');
     32        assert_equals(observedEntries[0].name, 'pointerdown');
     33    })).observe({ entryTypes: ['first-input'] });
     34    on_event(window, 'load', () => {
     35      clickAndBlockMain('button').then(() => {
     36        clickAndBlockMain('button').then(wait).then( () => {
     37          // After some wait, the PerformanceObserver should have processed both clicks.
     38          // One and only one first-input entry should have been dispatched, so
     39          // |hasObservedFirstInput| should be true.
     40          t.step_timeout( () => {
     41            assert_true(hasObservedFirstInput);
     42            t.done();
     43          }, 10);
     44        });
     45      });
     46    });
     47  },
     48  "Event Timing: check first-input for a PerformanceObserver observing only first-input."
     49  );
     50 </script>
     51 </html>