helper_scrollto_tap.html (2138B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width; initial-scale=1.0"> 6 <title>Sanity touch-tapping test</title> 7 <script type="application/javascript" src="apz_test_native_event_utils.js"></script> 8 <script type="application/javascript" src="apz_test_utils.js"></script> 9 <script src="/tests/SimpleTest/paint_listener.js"></script> 10 <script type="application/javascript"> 11 12 async function test() { 13 while (window.scrollY == 0) { 14 // the scrollframe is not yet marked as APZ-scrollable. Mark it so 15 // before continuing. 16 window.scrollTo(0, 1); 17 await promiseApzFlushedRepaints(); 18 } 19 20 // This is a scroll by 20px that should use paint-skipping if possible. 21 // If paint-skipping is enabled, this should not trigger a paint, but go 22 // directly to the compositor using an empty transaction. We check for this 23 // by ensuring the document element did not get painted. 24 var utils = window.opener.SpecialPowers.getDOMWindowUtils(window); 25 var elem = document.documentElement; 26 var skipping = location.search == "?true"; 27 utils.checkAndClearPaintedState(elem); 28 window.scrollTo(0, 20); 29 await promiseAllPaintsDone(); 30 31 if (skipping) { 32 is(utils.checkAndClearPaintedState(elem), false, "Document element didn't get painted"); 33 } 34 35 // After that's done, we click on the button to make sure the 36 // skipped-paint codepath still has working APZ event transformations. 37 let clickPromise = new Promise(resolve => { 38 document.addEventListener("click", resolve); 39 }); 40 41 await synthesizeNativeTap(document.getElementById("b"), 5, 5, function() { 42 dump("Finished synthesizing tap, waiting for button to be clicked...\n"); 43 }); 44 45 let clickEvent = await clickPromise; 46 is(clickEvent.target, document.getElementById("b"), "Clicked on button, yay! (at " + clickEvent.clientX + "," + clickEvent.clientY + ")"); 47 } 48 49 waitUntilApzStable() 50 .then(test) 51 .then(subtestDone, subtestFailed); 52 53 </script> 54 </head> 55 <body style="height: 5000px"> 56 <div style="height: 50px">spacer</div> 57 <button id="b" style="width: 10px; height: 10px"></button> 58 </body> 59 </html>