test_scrollframe_abspos_interrupt.html (1479B)
1 <!doctype html> 2 <title>Test for bug 1526609</title> 3 <script src="/tests/SimpleTest/SimpleTest.js"></script> 4 <script src="/tests/SimpleTest/EventUtils.js"></script> 5 <style> 6 body { 7 margin: 0; 8 } 9 .scroller { 10 overflow-y: auto; 11 position: relative; 12 width: 500px; 13 height: 300px; 14 } 15 .kid { 16 position: absolute; 17 width: 100%; 18 background: linear-gradient(to bottom, red, green); 19 line-height: 100px; 20 } 21 </style> 22 <div class="scroller" id="scroller"> 23 <div class="kid"></div> 24 </div> 25 <script> 26 { 27 let text = " foo bar "; 28 29 for (let i = 0; i < 16; ++i) 30 text = text + text; 31 document.querySelector(".kid").innerText = text; 32 } 33 34 SimpleTest.waitForExplicitFinish(); 35 36 const scroller = document.querySelector("#scroller"); 37 38 is(scroller.scrollTop, 0, "Initial scroll position"); 39 ok(scroller.scrollTopMax > 0, "Should be able to scroll down"); 40 41 scroller.scrollTop = scroller.scrollTopMax; 42 is(scroller.scrollTop, scroller.scrollTopMax, "Should've scrolled"); 43 44 const origWidth = scroller.offsetWidth; 45 const utils = SpecialPowers.DOMWindowUtils; 46 47 // Take control of the refresh driver 48 utils.advanceTimeAndRefresh(0); 49 50 // Force the next reflow to get interrupted 51 utils.forceReflowInterrupt(); 52 scroller.style.width = "300px"; 53 utils.advanceTimeAndRefresh(0); 54 55 isnot(scroller.scrollTop, 0, "Shouldn't have lost scroll position"); 56 isnot(scroller.offsetWidth, origWidth, "Should've had to reflow"); 57 58 utils.restoreNormalRefresh(); 59 SimpleTest.finish(); 60 </script>