tor-browser

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

buffered-and-duration-threshold.html (2044B)


      1 <!DOCTYPE html>
      2 <html>
      3 <meta charset=utf-8 />
      4 <title>Event Timing: PerformanceObserver with buffered flag and durationThreshold</title>
      5 <script src=/resources/testharness.js></script>
      6 <script src=/resources/testharnessreport.js></script>
      7 <script src=/resources/testdriver.js></script>
      8 <script src=/resources/testdriver-vendor.js></script>
      9 <script src=resources/event-timing-test-utils.js></script>
     10 <div id='myDiv'>Click me</div>
     11 <script>
     12 promise_test(async t => {
     13  assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
     14  // Add a PerformanceObserver and observe with a durationThreshold of 30 and buffered flag.
     15  return new Promise(async resolve1 => {
     16    // Add a slow click event and make sure it's dispatched to observers.
     17    await new Promise(async resolve2 => {
     18      // Observer to await until event entry is dispatched.
     19      new PerformanceObserver(() => {
     20        resolve2();
     21      }).observe({type: "event", durationThreshold: 16});
     22      await clickAndBlockMain('myDiv', { duration: 30 });
     23    });
     24    const afterFirstClick = performance.now();
     25    new PerformanceObserver(t.step_func(list => {
     26      const pointerDowns = list.getEntriesByName('pointerdown');
     27      pointerDowns.forEach(entry => {
     28        if (entry.processingStart < afterFirstClick) {
     29          // It is possible that the first event gets a slow duration and hence gets buffered.
     30          // In this case the minDuration must be at least 104, otherwise it shouldn't have been
     31          // buffered.
     32          verifyClickEvent(entry, 'myDiv', true /* isFirst */);
     33        } else {
     34          verifyClickEvent(pointerDowns[0], 'myDiv', false /* isFirst */, 16 /* minDuration*/);
     35          resolve1();
     36        }
     37      });
     38    })).observe({type: 'event', durationThreshold: 16, buffered: true});
     39    // This should be the only click observed since the other one would not be buffered.
     40    await clickAndBlockMain('myDiv', { duration: 30 } );
     41  });
     42 }, "PerformanceObserver buffering independent of durationThreshold");
     43 </script>
     44 </html>