helper_click.html (1373B)
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 mouse-clicking 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 clickButton() { 13 let clickPromise = new Promise(resolve => { 14 document.addEventListener("click", resolve); 15 }); 16 17 if (getQueryArgs().dtc) { 18 // force a dispatch-to-content region on the document 19 document.addEventListener("wheel", function() { /* no-op */ }, { passive: false }); 20 await promiseAllPaintsDone(); 21 await promiseOnlyApzControllerFlushed(); 22 } 23 24 await synthesizeNativeMouseEventWithAPZ( 25 { type: "click", target: document.getElementById("b"), offsetX: 5, offsetY: 5 }, 26 () => dump("Finished synthesizing click, waiting for button to be clicked...\n") 27 ); 28 29 let e = await clickPromise; 30 is(e.target, document.getElementById("b"), "Clicked on button, yay! (at " + e.clientX + "," + e.clientY + ")"); 31 } 32 33 waitUntilApzStable() 34 .then(clickButton) 35 .then(subtestDone, subtestFailed); 36 37 </script> 38 </head> 39 <body> 40 <button id="b" style="width: 10px; height: 10px"></button> 41 </body> 42 </html>