absolute-child-shift-with-parent-negative-overflow.html (1196B)
1 <!DOCTYPE html> 2 <title>Layout Instability: parent and overflowing absolute child moved together</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="parent" style="position: relative; left: 400px; top: 300px; width: 100px; height: 100px; background: yellow"> 8 <div id="child" style="position: absolute; top: -300px; left: -400px; width: 100px; height: 100px; background: blue"></div> 9 </div> 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 // Modify the position of the div. 19 const parent = document.querySelector("#parent"); 20 parent.style.top = '400px'; 21 22 // We should track parent and child separately. 23 const expectedScore = computeExpectedScore(100 * (100 + 100), 100) * 2; 24 25 // Observer fires after the frame is painted. 26 assert_equals(watcher.score, 0); 27 await watcher.promise; 28 assert_equals(watcher.score, expectedScore); 29 }, 'Parent and overflowing absolute child movement.'); 30 31 </script>