helper_overflowhidden_zoom.html (3231B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width, minimum-scale=1.0"> 6 <title>Tests that zooming in and out doesn't change the scroll position on an overflow hidden document</title> 7 <script type="application/javascript" src="apz_test_utils.js"></script> 8 <script type="application/javascript" src="apz_test_native_event_utils.js"></script> 9 <script src="/tests/SimpleTest/paint_listener.js"></script> 10 <style> 11 html,body { 12 overflow: hidden; 13 } 14 </style> 15 </head> 16 <body> 17 <div style="height: 20000px; background-color: green"></div> 18 <script> 19 const utils = SpecialPowers.getDOMWindowUtils(window); 20 21 async function test() { 22 is(await getResolution(), 1.0, "should not be zoomed (1)"); 23 24 is(window.scrollX, 0, "shouldn't have scrolled (2)"); 25 is(window.scrollY, 0, "shouldn't have scrolled (3)"); 26 is(visualViewport.pageTop, 0, "shouldn't have scrolled (4)"); 27 is(visualViewport.pageLeft, 0, "shouldn't have scrolled (5)"); 28 29 // Force reconstruction of the root scroll frame to trigger bug 1665332. 30 document.documentElement.style.display = "flex"; 31 document.documentElement.offsetLeft; 32 document.documentElement.style.display = ""; 33 document.documentElement.offsetLeft; 34 35 is(await getResolution(), 1.0, "should not be zoomed (6)"); 36 37 is(window.scrollX, 0, "shouldn't have scrolled (7)"); 38 is(window.scrollY, 0, "shouldn't have scrolled (8)"); 39 is(visualViewport.pageTop, 0, "shouldn't have scrolled (9)"); 40 is(visualViewport.pageLeft, 0, "shouldn't have scrolled (10)"); 41 42 // Zoom in 43 SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(4.0); 44 await promiseApzFlushedRepaints(); 45 46 is(await getResolution(), 4.0, "should be zoomed (11)"); 47 48 is(window.scrollX, 0, "shouldn't have scrolled (12)"); 49 is(window.scrollY, 0, "shouldn't have scrolled (13)"); 50 is(visualViewport.pageTop, 0, "shouldn't have scrolled (14)"); 51 is(visualViewport.pageLeft, 0, "shouldn't have scrolled (15)"); 52 53 // Scroll so the visual viewport offset is non-zero 54 utils.scrollToVisual(20000, 20000, utils.UPDATE_TYPE_MAIN_THREAD, 55 utils.SCROLL_MODE_INSTANT); 56 57 await promiseApzFlushedRepaints(); 58 59 is(await getResolution(), 4.0, "should be zoomed (16)"); 60 61 is(window.scrollX, 0, "shouldn't have scrolled (17)"); 62 is(window.scrollY, 0, "shouldn't have scrolled (18)"); 63 isnot(visualViewport.pageTop, 0, "should have scrolled (19)"); 64 isnot(visualViewport.pageLeft, 0, "should have scrolled (20)"); 65 66 // Zoom back out 67 SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(1.0); 68 await promiseApzFlushedRepaints(); 69 70 is(await getResolution(), 1.0, "should not be zoomed (21)"); 71 72 is(window.scrollX, 0, "shouldn't have scrolled (22)"); 73 is(window.scrollY, 0, "shouldn't have scrolled (23)"); 74 is(visualViewport.pageTop, 0, "shouldn't have scrolled (24)"); 75 is(visualViewport.pageLeft, 0, "shouldn't have scrolled (25)"); 76 } 77 78 waitUntilApzStable() 79 .then(test) 80 .then(subtestDone, subtestFailed); 81 </script> 82 </body> 83 </html>