helper_bug1724759.html (1730B)
1 <!DOCTYPE html> 2 <html> 3 <meta name="viewport" content="width=device-width; initial-scale=1.0"> 4 <title>Tests that :active state is cleared after a longpress event</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <script src="/tests/SimpleTest/paint_listener.js"></script> 7 <script src="apz_test_utils.js"></script> 8 <script src="apz_test_native_event_utils.js"></script> 9 <style> 10 #button { 11 width: 100px; 12 height: 100px; 13 } 14 </style> 15 <button id="button">Button</button> 16 <script> 17 async function test() { 18 const contextmenuPromise = promiseOneEvent(button, "contextmenu", e => { 19 e.preventDefault(); 20 return true; 21 }); 22 await synthesizeNativeTouch(button, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT); 23 24 // In JS there's no way to ensure `APZStateChange::eStartTouch` notification 25 // has been processed. So we wait for `:active` state change here. 26 await SimpleTest.promiseWaitForCondition( 27 () => button.matches(":active"), 28 "Waiting for :active state change"); 29 30 ok(button.matches(":active"), "should be active"); 31 32 await contextmenuPromise; 33 34 await synthesizeNativeTouch(button, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE); 35 36 // Same as above. We need to wait for not `:active` state here. 37 await SimpleTest.promiseWaitForCondition( 38 () => !button.matches(":active"), 39 "Waiting for :active state change"); 40 41 ok(!button.matches(":active"), "should not be active"); 42 } 43 44 if (getPlatform() == "windows") { 45 // On Windows every context menu on touch screens opens __after__ lifting the 46 // finger. 47 ok(true, "Test doesn't need to run on Windows"); 48 subtestDone(); 49 } else { 50 waitUntilApzStable() 51 .then(test) 52 .then(subtestDone, subtestFailed); 53 } 54 </script> 55 </html>