helper_hover_state.html (1631B)
1 <!DOCTYPE html> 2 <html> 3 <meta name="viewport" content="width=device-width; initial-scale=1.0"> 4 <title>Tests that :hover state is changed right after touchstart</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 html { height:200vh; } 11 .test:hover { background:lime; } 12 .test { 13 border: 5px solid black; 14 height: 100px; 15 margin: 50px; 16 display: block; 17 } 18 </style> 19 <div class="test">DIV: Tap me and scroll</div> 20 <script> 21 async function test() { 22 const target = document.querySelector(".test"); 23 const touchStartPromise = promiseOneEvent(target, "touchstart"); 24 const touchEndPromise = promiseOneEvent(target, "touchend"); 25 await promiseApzFlushedRepaints(); 26 27 await synthesizeNativeTouch(target, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT); 28 await touchStartPromise; 29 30 await promiseFrame(); 31 await promiseFrame(); 32 ok(target.matches(":hover"), "should be hover"); 33 34 await synthesizeNativeTouch(target, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE); 35 await touchEndPromise; 36 37 await promiseFrame(); 38 await promiseFrame(); 39 ok(target.matches(":hover"), "should be still hover"); 40 } 41 42 if (getPlatform() == "windows") { 43 // Bug 1875916. On Windows synthesizeNativeTouch(TOUCH_REMOVE) causes 44 // `InjectTouchInput failure` with ERROR_TIMEOUT. 45 ok(true, "Test doesn't need to run on Windows"); 46 subtestDone(); 47 } else { 48 waitUntilApzStable() 49 .then(test) 50 .then(subtestDone, subtestFailed); 51 } 52 </script> 53 </html>