blob: c84d4eff6b8779953bcde54eb5169f0ffa1c6314 [file] [log] [blame]
Nicolás Peña Morenocd2c04e2019-05-09 23:24:541<!DOCTYPE html>
2<html>
3<meta charset=utf-8 />
4<div id='div' onclick='delay()'>Click me</div>
5<div id='div2'>No, click me!</div>
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
Nicolás Peña Morenoaa9d7f52019-05-14 22:20:0611<script src=resources/event-timing-test-utils.js></script>
Nicolás Peña Morenocd2c04e2019-05-09 23:24:5412<script>
13 let delayCalled = false;
14 let beforeClick;
15 function delay() {
16 const end = performance.now() + 150;
17 while(performance.now() < end) {}
18 delayCalled = true;
19 }
20 async_test(function(t) {
Nicolás Peña Moreno32a1ff62019-07-19 14:38:2721 if (!window.PerformanceEventTiming)
22 assert_unreached("PerformanceEventTiming is not supported");
23
Nicolás Peña Morenocd2c04e2019-05-09 23:24:5424 const observer = new PerformanceObserver(t.step_func_done((entryList) => {
Nicolás Peña Morenoaa9d7f52019-05-14 22:20:0625 const entries = entryList.getEntries().filter(e => e.name === 'mousedown');
Nicolás Peña Morenocd2c04e2019-05-09 23:24:5426 // There must only be one click entry: from the clickAndBlockMain() call.
27 assert_equals(entries.length, 1);
28 const entry = entries[0];
29 // This ensures that the entry is exposing timing from the second click, i.e.
30 // the one from the clickAndBlockMain() call.
31 assert_greater_than_equal(entry.processingStart, beforeClick);
Nicolás Peña Morenoaa9d7f52019-05-14 22:20:0632 // Check that the first input entry was also from the second click.
Nicolás Peña Morenof1a492a2019-07-04 15:09:3033 const firstInput = performance.getEntriesByType('first-input');
Nicolás Peña Morenoaa9d7f52019-05-14 22:20:0634 assert_equals(firstInput.length, 1);
35 assert_greater_than_equal(firstInput[0].processingStart, beforeClick);
Nicolás Peña Morenocd2c04e2019-05-09 23:24:5436 }));
Nicolás Peña Morenoaa9d7f52019-05-14 22:20:0637 observer.observe({entryTypes: ['event']});
Nicolás Peña Morenocd2c04e2019-05-09 23:24:5438 document.getElementById('div').click();
39 // Take the timestamp after the programmatic click but before the next click.
40 beforeClick = performance.now();
41 // After the programmatic click, use another input to know when entries have been
42 // dispatched to the PerformanceObserver callback.
43 clickAndBlockMain('div2');
44 }, "Event Timing: events from programmatic click are not observed");
45</script>
46</html>