helper_scrollIntoView_bug1950744.html (1781B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1"> 6 <title>Bug 1950744 Testcase</title> 7 <script src="apz_test_native_event_utils.js"></script> 8 <script src="apz_test_utils.js"></script> 9 <script src="/tests/SimpleTest/paint_listener.js"></script> 10 </head> 11 <style> 12 #fixed { 13 max-width: 315px; 14 width: 300px; 15 visibility: hidden; 16 left: -295px; 17 position: fixed; 18 } 19 html { 20 height: 10000px; 21 scroll-behavior: auto; /* to make scrolling instant */ 22 } 23 body { 24 width: 100%; 25 background: linear-gradient(yellow, blue); 26 } 27 </style> 28 <body> 29 <div id="fixed"> 30 <div id="target"></div> 31 </div> 32 <script> 33 async function test() { 34 is(window.scrollY, 0, "The initial scroll offset should be 0"); 35 is(visualViewport.scale, 1.0, "The document should not get scaled"); 36 is(visualViewport.pageTop, 0, "The initial visual viewport pageTop should be 0"); 37 38 // Scroll the root scroll container. 39 const scrollendPromise = promiseScrollend(window); 40 window.scrollTo(0, 2000); 41 is(window.scrollY, 2000, "Now the scroll offset should be 2000"); 42 await scrollendPromise; 43 44 visualViewport.addEventListener("scroll", () => { 45 ok(false, "Any VisualViewport scroll event should not be observed"); 46 }); 47 window.addEventListener("scroll", () => { 48 ok(false, "Any scroll event should not be observed"); 49 }); 50 51 document.querySelector("#target").scrollIntoView(); 52 53 await promiseApzFlushedRepaints(); 54 55 // Wait two frames to give a chance to scroll. 56 await promiseFrame(); 57 await promiseFrame(); 58 59 is(window.scrollY, 2000, "The scroll offset should stay at 2000px"); 60 } 61 62 waitUntilApzStable() 63 .then(test) 64 .then(subtestDone, subtestFailed); 65 </script> 66 </body> 67 </html>