DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

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