| Xianzhu Wang | 85a49cb | 2020-12-16 18:18:45 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <title>Layout Instability: visibility:hidden change with layout</title> |
| 3 | <link rel="help" href="https://wicg.github.io/layout-instability/" /> |
| Xianzhu Wang | 48e5e3c | 2021-03-13 00:30:33 | [diff] [blame^] | 4 | <div id="target" style="position: absolute; top: 0; width: 200px; height: 200px; visibility: hidden; background: blue"></div> |
| Xianzhu Wang | 85a49cb | 2020-12-16 18:18:45 | [diff] [blame] | 5 | <script src="/resources/testharness.js"></script> |
| 6 | <script src="/resources/testharnessreport.js"></script> |
| 7 | <script src="resources/util.js"></script> |
| 8 | <script> |
| 9 | |
| 10 | promise_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> |