Xianzhu Wang | 3a36f4a | 2020-11-05 18:21:55 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <title>Layout Instability: movement of fixed position</title> |
| 3 | <link rel="help" href="https://wicg.github.io/layout-instability/" /> |
| 4 | <script src="/resources/testharness.js"></script> |
| 5 | <script src="/resources/testharnessreport.js"></script> |
| 6 | <script src="resources/util.js"></script> |
| 7 | <div id="target" style="position: fixed; top: 100px; width: 300px; height: 200px; background: yellow"> |
| 8 | </div> |
| 9 | <script> |
| 10 | promise_test(async () => { |
| 11 | const watcher = new ScoreWatcher; |
| 12 | |
| 13 | // Wait for the initial render to complete. |
| 14 | await waitForAnimationFrames(2); |
| 15 | |
| 16 | // Modify the position of the div. |
| 17 | target.style.top = '200px'; |
| 18 | |
| 19 | const expectedScore = computeExpectedScore(300 * (200 + 100), 100); |
| 20 | |
| 21 | // Observer fires after the frame is painted. |
| 22 | assert_equals(watcher.score, 0); |
| 23 | await watcher.promise; |
| 24 | assert_equals(watcher.score, expectedScore); |
| 25 | }, 'Movement of fixed position'); |
| 26 | |
| 27 | </script> |