helper_bug1989868.html (1551B)
1 <!DOCTYPE html> 2 <html> 3 <meta name="viewport" content="width=device-width; initial-scale=1.0"> 4 <title>Test that touch scrolling keeps working with a smooth scroll operation by JS</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <script src="/tests/SimpleTest/EventUtils.js"></script> 7 <script src="/tests/SimpleTest/paint_listener.js"></script> 8 <script src="apz_test_utils.js"></script> 9 <script src="apz_test_native_event_utils.js"></script> 10 <style> 11 body { 12 margin: 0px; 13 padding: 0px; 14 } 15 </style> 16 <div style="width: 100vw; height: 300vh;"></div> 17 <script> 18 async function test() { 19 let scrollYInEventHandler; 20 window.addEventListener("scroll", () => { 21 scrollYInEventHandler = window.scrollY; 22 // Trigger a smooth scroll. 23 window.scrollTo({top: 0, behavior: "smooth"}); 24 }, { once: true }); 25 26 // Send touch events to scroll down the content. 27 // Note that each touch event needs to be sent in each frame to 28 // give a chance to receive a scroll event while sending the evets. 29 for (let y = 200; y > 0; y -= 10) { 30 await synthesizeNativeTouch(window, 100, y, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT); 31 await promiseFrame(); 32 } 33 34 ok(scrollYInEventHandler * 2 <= window.scrollY, 35 `The last scroll position ${window.scrollY} should be greater than the 36 double of the position in scroll event handler ${scrollYInEventHandler}`); 37 38 await synthesizeNativeTouch(window, 100, 0, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE); 39 } 40 41 waitUntilApzStable() 42 .then(test) 43 .then(subtestDone, subtestFailed); 44 </script> 45 </html>