add-remove-position-fixed.html (1029B)
1 <!DOCTYPE html> 2 <title>Layout Instability: no shift for adding/removing position:fixed</title> 3 <link rel="help" href="https://wicg.github.io/layout-instability/" /> 4 <div id="target" style="width: 100px; height: 100px; background: green; 5 position: absolute; top: 200px"></div> 6 <div style="height: 2000px"></div> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="resources/util.js"></script> 10 <script> 11 12 promise_test(async () => { 13 const watcher = new ScoreWatcher; 14 15 // Wait for the initial render to complete. 16 await waitForAnimationFrames(2); 17 18 window.scrollTo(0, 1000); 19 target.style.position = 'fixed'; 20 target.style.top = 0; 21 22 await waitForAnimationFrames(3); 23 assert_equals(watcher.score, 0); 24 25 window.scrollTo(0, 100); 26 target.style.position = 'absolute'; 27 target.style.top = '200px'; 28 29 await waitForAnimationFrames(3); 30 assert_equals(watcher.score, 0); 31 }, "No shift for adding/removing position:fixed."); 32 33 </script>