summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/event-timing/retrievability.html
blob: ab475fc52974fe2afde355332653c802c7c5f16f (plain)
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
41
42
43
44
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<title>Event Timing: make sure 'event' entries are not retrievable by performance.getEntries* APIs.</title>
<meta name="timeout" content="long">
<button id='button'>Generate a 'click' event</button>
<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>

<script>
  function validateEntries() {
    const entriesByName = performance.getEntriesByName('mousedown', 'event');
    const entriesByType = performance.getEntriesByType('event');
    const allEntries = performance.getEntries();
    assert_equals(entriesByName.length, 0, 'Event Timing entry should not be retrievable by getEntriesByName');
    assert_equals(entriesByType.length, 0, 'Event Timing entry should not be retrievable by getEntriesByType');
    assert_equals(allEntries.filter(e => e.entryType === 'event').length, 0, 'Event Timing entry should not be retrievable by getEntries');
  }

  /* Timeline:
     Begin Busy Loop
     Click 1 arrives
     End Busy Loop
     (Dispatch and Process Click 1 - buffered)
     Onload Event Fires
     Validate entries
  */
  async_test(function(t) {
    assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
    new PerformanceObserver(t.step_func(entryList => {
      if (entryList.getEntriesByName('mousedown').length > 0) {
        validateEntries();
        t.done();
      }
    })).observe({entryTypes: ['event']});
    clickAndBlockMain('button');
  }, "Event Timing: make sure event-timing entries are not retrievable by performance.getEntries*.");

</script>
</html>