blob: 35ee0d9ed898217272ec101246ef6deefbb84a38 [file] [log] [blame]
Xianzhu Wang85a49cb2020-12-16 18:18:451<!DOCTYPE html>
2<title>Layout Instability: visibility:hidden change with layout</title>
3<link rel="help" href="https://wicg.github.io/layout-instability/" />
Xianzhu Wang48e5e3c2021-03-13 00:30:334<div id="target" style="position: absolute; top: 0; width: 200px; height: 200px; visibility: hidden; background: blue"></div>
Xianzhu Wang85a49cb2020-12-16 18:18:455<script src="/resources/testharness.js"></script>
6<script src="/resources/testharnessreport.js"></script>
7<script src="resources/util.js"></script>
8<script>
9
10promise_test(async () => {
11 const watcher = new ScoreWatcher;
12
13 // Wait for the initial render to complete.
14 await waitForAnimationFrames(2);
15
16 // Shift target, for which no shift should be reported because it's hidden.
17 target.style.top = '200px';
18 target.style.visibility = 'visible';
19
20 await waitForAnimationFrames(2);
21 // No shift should be reported.
22 assert_equals(watcher.score, 0);
23
24 // Shift again, for which shift should be reported.
25 target.style.top = '300px';
26
27 await watcher.promise;
28 const expectedScore = computeExpectedScore(200 * (200 + 100), 100);
29 assert_equals(watcher.score, expectedScore);
30
31}, 'visibility:hidden change with layout');
32
33</script>