helper_visualscroll_nonrcd_rsf.html (3153B)
1 <!DOCTYPE HTML> 2 <meta charset="utf-8"> 3 <meta name="viewport" content="width=device-width, minimum-scale=1.0"> 4 <title>Tests that pending visual scroll positions on RSFs of non-RCDs get cleared properly</title> 5 <script src="apz_test_utils.js"></script> 6 <script src="apz_test_native_event_utils.js"></script> 7 <script src="/tests/SimpleTest/paint_listener.js"></script> 8 <body> 9 <iframe style="width: 300px; height: 300px" id="scroller"></iframe> 10 <script> 11 function populateScroller() { 12 let text = '<div id="line0">line 0</div><br>'; 13 for (let i = 1; i < 100; i++) { 14 text += 'line ' + i + '<br>'; 15 } 16 document.querySelector('#scroller').contentDocument.body.innerHTML = text; 17 } 18 19 function reconstructScroller() { 20 let scroller = document.querySelector('#scroller'); 21 scroller.style.display = 'none'; 22 /* eslint-disable no-unused-vars */ 23 let dummyToForceFlush = scroller.scrollTop; 24 scroller.style.display = ''; 25 dummyToForceFlush = scroller.scrollTop; 26 } 27 28 async function test() { 29 let scroller = document.querySelector('#scroller'); 30 let subwin = scroller.contentWindow; 31 32 populateScroller(); 33 subwin.scrollTo(0, 100); 34 is(subwin.scrollY, 100, 'Scroller scrolled down to y=100'); 35 36 // let the visual scroll position round-trip through APZ 37 await promiseApzFlushedRepaints(); 38 39 // frame reconstruction does a ScrollToVisual. The bug is that the pending 40 // visual scroll offset update never gets cleared even though the paint 41 // transaction should clear it. 42 reconstructScroller(); 43 await promiseApzFlushedRepaints(); 44 45 // Scroll back up to the top using APZ-side scrolling, and wait for the APZ 46 // wheel animation to complete and the final scroll position to get synced 47 // back to the main thread. The large -250 scroll delta required here is due 48 // to bug 1662487. 49 await promiseMoveMouseAndScrollWheelOver(subwin, 10, 10, true, -250); 50 let utils = SpecialPowers.getDOMWindowUtils(window); 51 for (let i = 0; i < 60; i++) { 52 utils.advanceTimeAndRefresh(16); 53 } 54 utils.restoreNormalRefresh(); 55 await promiseApzFlushedRepaints(); 56 is(subwin.scrollY, 0, 'Scroller scrolled up to y=0'); 57 58 // Do a mouse-drag-selection. I couldn't find any simpler way to reproduce 59 // the problem. 60 const kMouseMovePixels = 10; 61 let promiseMouseMovesDone = new Promise((resolve) => { 62 let mouseDownX = 0; 63 subwin.document.documentElement.addEventListener('mousedown', (e) => { 64 dump(`Got mousedown at ${e.screenX}\n`); 65 mouseDownX = e.screenX; 66 }); 67 subwin.document.documentElement.addEventListener('mousemove', (e) => { 68 // Mousemove events can get squashed together so we check the coord 69 // instead. 70 dump(`Got mousemove at ${e.screenX}\n`); 71 if (e.screenX - mouseDownX >= kMouseMovePixels) { 72 resolve(); 73 } 74 }); 75 }); 76 let line0 = subwin.document.querySelector('#line0'); 77 let dragFinisher = await promiseNativeMouseDrag(line0, 1, 5, kMouseMovePixels, 0, kMouseMovePixels); 78 await promiseMouseMovesDone; 79 await dragFinisher(); 80 81 is(subwin.scrollY, 0, 'Scroller should remain at y=0'); 82 } 83 84 waitUntilApzStable() 85 .then(test) 86 .then(subtestDone, subtestFailed); 87 </script>