child-shift-with-parent.html (994B)
1 <!DOCTYPE html> 2 <title>Layout Instability: parent/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; width: 100px; height: 100px; border: 100px solid blue"> 8 <div id="child" style="height: 300px"></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 = '100px'; 21 22 const expectedScore = computeExpectedScore(300 * (400 + 100), 100); 23 24 // Observer fires after the frame is painted. 25 assert_equals(watcher.score, 0); 26 await watcher.promise; 27 assert_equals(watcher.score, expectedScore); 28 }, 'Parent/child movement.'); 29 30 </script>