inline-flow-shift.html (1530B)
1 <!DOCTYPE html> 2 <title>Layout Instability: inline/text 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/util.js"></script> 7 <div style="width: 200px; font-size: 20px; line-height: 25px"> 8 1AAAAAAA<br> 9 2AAAAAAA<br> 10 3AAAAAAA<br> 11 <div id="inline-block" style="display: inline-block; height: 50px">4AAAAAAA</div><br> 12 5AAAAAAA<br> 13 6AAAAAAA<br> 14 7AAAAAAA<br> 15 </div> 16 <script> 17 18 promise_test(async () => { 19 const watcher = new ScoreWatcher; 20 21 // Wait for the initial render to complete. 22 await waitForAnimationFrames(2); 23 24 // Modify the position of the div. 25 const inline_block = document.querySelector("#inline-block"); 26 inline_block.style.height = '100px'; 27 28 // The lines below the inline-block are shifted down by 50px. 29 // The implementation may measure the real width of the shifted text 30 // or use the available width (i.e. width of the containing block). 31 // Also tolerate extra 10% error. 32 const text_width = inline_block.offsetWidth; 33 const expectedScoreMin = computeExpectedScore(text_width * (30 * 3 + 50), 50) * 0.9; 34 const expectedScoreMax = computeExpectedScore(200 * (30 * 3 + 50), 50) * 1.1; 35 36 // Observer fires after the frame is painted. 37 assert_equals(watcher.score, 0); 38 await watcher.promise; 39 assert_between_exclusive(watcher.score, expectedScoreMin, expectedScoreMax); 40 }, 'Inline flow movement.'); 41 42 </script>