helper_hover_state_while_scroll.html (2054B)
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 with an active `touchmove` event listener</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 const scrollPromise = promiseOneEvent(window, "scroll"); 26 await promiseApzFlushedRepaints(); 27 28 await synthesizeNativeTouch(target, 10, 10, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT); 29 await touchStartPromise; 30 31 await promiseFrame(); 32 await promiseFrame(); 33 ok(target.matches(":hover"), "should be hover"); 34 35 await synthesizeNativeTouch(target, 10, 5, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT); 36 await synthesizeNativeTouch(target, 10, 1, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT); 37 38 await scrollPromise; 39 ok(window.scrollY > 0, `scrolled to ${window.scrollY}`); 40 await promiseFrame(); 41 ok(target.matches(":hover"), "should be still hover"); 42 43 await synthesizeNativeTouch(target, 10, 1, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE); 44 await touchEndPromise; 45 46 await promiseFrame(); 47 await promiseFrame(); 48 ok(target.matches(":hover"), "should be still hover"); 49 } 50 51 if (getPlatform() == "windows") { 52 // Bug 1875916. On Windows synthesizeNativeTouch(TOUCH_REMOVE) causes 53 // `InjectTouchInput failure` with ERROR_TIMEOUT. 54 ok(true, "Test doesn't need to run on Windows"); 55 subtestDone(); 56 } else { 57 waitUntilApzStable() 58 .then(test) 59 .then(subtestDone, subtestFailed); 60 } 61 </script> 62 </html>