helper_hittest_checkerboard.html (2135B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>APZ hit-testing over a checkerboarded area</title> 5 <script type="application/javascript" src="apz_test_utils.js"></script> 6 <script type="application/javascript" src="apz_test_native_event_utils.js"></script> 7 <script src="/tests/SimpleTest/paint_listener.js"></script> 8 <meta name="viewport" content="width=device-width"/> 9 </head> 10 <body> 11 <div id="scroller" style="width: 300px; height: 300px; overflow:scroll; margin-top: 100px; margin-left: 50px"> 12 <!-- Make the contents tall enough to be sure we can checkerboard --> 13 <div id="contents" style="width: 100%; height: 5000px; background-image: linear-gradient(blue,red)"> 14 </div> 15 </div> 16 <div id="make_root_scrollable" style="height: 5000px"></div> 17 </body> 18 <script type="application/javascript"> 19 20 async function test() { 21 var config = getHitTestConfig(); 22 var utils = config.utils; 23 24 var scroller = document.getElementById("scroller"); 25 26 // Activate the scrollframe but keep the main-thread scroll position at 0. 27 // Also apply an async scroll offset in the y-direction such that the 28 // scrollframe scrolls all the way to the bottom of its range, where it's 29 // sure to checkerboard. 30 utils.setDisplayPortForElement(0, 0, 300, 1000, scroller, 1); 31 await promiseApzFlushedRepaints(); 32 var scrollY = scroller.scrollTopMax; 33 utils.setAsyncScrollOffset(scroller, 0, scrollY); 34 // Tick the refresh driver once to make sure the compositor has applied the 35 // async scroll offset (for WebRender hit-testing we need to make sure WR has 36 // the latest info). 37 utils.advanceTimeAndRefresh(16); 38 utils.restoreNormalRefresh(); 39 40 var scrollerViewId = utils.getViewId(scroller); 41 42 // Hit-test the middle of the scrollframe, which is now inside the 43 // checkerboarded region, and check that we hit the scrollframe and 44 // not its parent. 45 checkHitResult(hitTest(centerOf(scroller)), 46 APZHitResultFlags.VISIBLE, 47 scrollerViewId, 48 utils.getLayersId(), 49 "active scrollframe"); 50 } 51 52 waitUntilApzStable() 53 .then(test) 54 .then(subtestDone, subtestFailed); 55 56 </script> 57 </html>