simple-block-movement.html (1050B)
1 <!DOCTYPE html> 2 <title>Layout Instability: simple block movement is detected</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/test-adapter.js"></script> 7 <script src="resources/util.js"></script> 8 <style> 9 #shifter { position: relative; width: 300px; height: 200px; background: blue; } 10 </style> 11 <div id="shifter"></div> 12 <script> 13 14 const watcher = new ScoreWatcher; 15 promise_test(async () => { 16 // Wait for the initial render to complete. 17 await waitForAnimationFrames(2); 18 19 // Modify the position of the div. 20 document.querySelector("#shifter").style = "top: 160px"; 21 22 // An element of size (300 x 200) has shifted by 160px. 23 const expectedScore = computeExpectedScore(300 * (200 + 160), 160); 24 25 // Observer fires after the frame is painted. 26 cls_expect(watcher, {score: 0}); 27 await watcher.promise; 28 cls_expect(watcher, {score: expectedScore}); 29 }, 'Simple block movement.'); 30 31 </script>