helper_checkerboard_zoom_during_load.html (2185B)
1 <!DOCTYPE html> 2 <html lang="en"><head> 3 <meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta charset="utf-8"> 4 <title>Testcase for checkerboarding after zooming during page load</title> 5 <script type="application/javascript" src="apz_test_utils.js"></script> 6 <script src="/tests/SimpleTest/paint_listener.js"></script> 7 <meta name="viewport" content="width=device-width"/> 8 <style> 9 body, html { 10 margin: 0; 11 } 12 </style> 13 <body> 14 <div style="height: 5000px; background-color: green"></div> 15 </body> 16 <script type="application/javascript"> 17 18 // This function runs after page load, but simulates what might happen if 19 // the user does a zoom during page load. It's hard to actually do this 20 // during page load, because the specific behaviour depends on interleaving 21 // between paints and the load event which is hard to control from a test. 22 // So instead, we do the zoom after page load, and then trigger a MVM reset 23 // which simulates what happens during the pageload process. 24 async function test() { 25 var utils = SpecialPowers.getDOMWindowUtils(window); 26 27 // Make it so that the layout and visual viewports diverge. We do this by 28 // zooming and then moving the visual viewport. 29 utils.setResolutionAndScaleTo(2); 30 var x = window.innerWidth / 2; 31 var y = window.innerHeight / 2; 32 utils.scrollToVisual(x, y, utils.UPDATE_TYPE_MAIN_THREAD, utils.SCROLL_MODE_INSTANT); 33 dump("Done scrollToVisual\n"); 34 35 // Next, kick off a paint transaction to APZ, so that it sets appropriate 36 // displayport margins with visual/layout adjustment factors. 37 await promiseApzFlushedRepaints(); 38 39 // Once that's done, we want to trigger the MobileViewportManager to update 40 // the displayport margins. 41 dump("Resetting MVM...\n"); 42 utils.resetMobileViewportManager(); 43 44 // The bug is that at this point, paints end up checkerboarding because the 45 // MVM code to update the displayport margins doesn't preserve the layout 46 // adjustment factor needed. 47 utils.advanceTimeAndRefresh(0); 48 assertNotCheckerboarded(utils, utils.getViewId(document.scrollingElement), `Should not see checkerboarding`); 49 } 50 51 waitUntilApzStable() 52 .then(test) 53 .then(subtestDone, subtestFailed); 54 55 </script>