summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/long-animation-frame/tentative/loaf-basic.html
blob: c6d3f8e32a293a4a66af0830d0e7c275ac785f5f (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
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Long Animation Frame Timing: basic</title>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>

<body>
<h1>Long Animation Frame: basic</h1>
<div id="log"></div>
<script>

promise_test(async t => {
    await expect_long_frame(() => busy_wait(), t);
}, 'A long busy wait is a long animation frame');

promise_test(async t => {
    await expect_long_frame(() => requestAnimationFrame(busy_wait), t);
}, 'A long busy wait in a requestAnimationFrame is a long animation frame');

promise_test(async t => {
    const segment_duration = very_long_frame_duration / 2;
    const entry = await expect_long_frame(async () => {
        busy_wait(segment_duration);
        await new Promise(resolve => requestAnimationFrame(() => {
            busy_wait(segment_duration)
            resolve();
        }));
    }, t);

    assert_not_equals(entry, "timeout");
    assert_greater_than_equal(entry.renderStart - entry.startTime, segment_duration);
}, 'A long busy wait split between a task and a requestAnimationFrame is a long animation frame');

promise_test(async t => {
    const segment_duration = very_long_frame_duration / 3;
    const entry = await expect_long_frame(async () => {
        const element = document.createElement("div");
        document.body.appendChild(element);
        t.add_cleanup(() => element.remove());
        busy_wait(segment_duration);
        requestAnimationFrame(() => {
            busy_wait(segment_duration);
        });

        new ResizeObserver(() => {
            busy_wait(segment_duration);
        }).observe(element);
    }, t);

    assert_not_equals(entry, "timeout");
    assert_greater_than_equal(entry.renderStart - entry.startTime, segment_duration);
    assert_greater_than_equal(entry.styleAndLayoutStart - entry.renderStart, segment_duration);
}, 'ResizeObservers should create a long-frame and affect layoutStartTime');
</script>
</body>