summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/long-animation-frame/tentative/loaf-ui-event-render-start.html
blob: 01d50d47e98ab33fce9b0e3596216bef3d184cbd (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
45
46
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Long Animation Frame Timing: UI events and renderStart</title>
<meta name="timeout" content="long">
<script src=/resources/testdriver.js></script>
<script src=/resources/testdriver-actions.js></script>
<script src=/resources/testdriver-vendor.js></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>

<body>
<h1>Long Animation Frame: UI events and renderStart</h1>
<div id="log"></div>
<script>

promise_test(async t => {
  const BUSY_DURATION_1 = 150;
  const BUSY_DURATION_2 = 250;
  const eventPromise = new Promise(resolve => document.body.addEventListener("pointermove", () => {
    busy_wait(BUSY_DURATION_1);
    requestAnimationFrame(() => busy_wait(BUSY_DURATION_2));
    resolve();
  }, {passive: true}));
  const actions = new test_driver.Actions();
  await actions.pointerMove(10, 10, {origin: document.body})
    .pointerDown()
    .pointerMove(3, 3)
    .pointerUp()
    .send();

  const scriptPredicate = s => s.invoker === "BODY.onpointermove";

  const loaf = await new Promise(resolve =>
    new PerformanceObserver(entries => {
      const entry = entries.getEntries().find(
        e => e.scripts.some(scriptPredicate));
      resolve(entry);
    }).observe({type: "long-animation-frame", buffered: true}));

  const script = loaf.scripts.find(scriptPredicate)
  assert_greater_than_equal(loaf.renderStart, script.startTime + script.duration);
  assert_greater_than_equal(loaf.blockingDuration, BUSY_DURATION_1 + BUSY_DURATION_2 - 50);
}, "UI events should always be before renderStart but still affect blockingDuration")
</script>
</body>