helper_wheelevents_handoff_on_iframe.html (2158B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta name="viewport" content="width=device-width; initial-scale=1.0"> 5 <title>Test that wheel events on an unscrollable OOP iframe are handoff-ed</title> 6 <script src="apz_test_utils.js"></script> 7 <script src="/tests/SimpleTest/EventUtils.js"></script> 8 <script src="/tests/SimpleTest/paint_listener.js"></script> 9 <style> 10 iframe { 11 height: 201px; 12 border: none; 13 } 14 </style> 15 </head> 16 <body> 17 <div id="iframe-container" style="overflow-y: scroll; height: 200px;"> 18 <iframe src="https://example.com/tests/gfx/layers/apz/test/mochitest/helper_wheelevents_handoff_on_iframe_child.html"></iframe> 19 </div> 20 <div style="height: 200vh;"></div> 21 <script type="application/javascript"> 22 async function test() { 23 const scrollContainer = document.querySelector("#iframe-container"); 24 25 let scrollEventPromise = promiseOneEvent(scrollContainer, "scroll"); 26 let scrollendEventPromise = promiseOneEvent(scrollContainer, "scrollend"); 27 28 // Send a wheel event on the iframe. 29 const iframe = document.querySelector("iframe"); 30 31 const scrollEvent = { 32 deltaY: 50, 33 asyncEnabled: true, 34 }; 35 synthesizeWheel(iframe, 50, 50, scrollEvent); 36 37 await scrollEventPromise; 38 await scrollendEventPromise; 39 40 // The wheel event should be handoff-ed to the parent scroll container. 41 is(scrollContainer.scrollTop, scrollContainer.scrollTopMax, 42 "The scroll position in the parent scroll container should be at the bottom"); 43 44 // Make sure the wheel event wasn't handoff-ed to the root scroller. 45 is(window.scrollY, 0, "The root scroll position should be 0"); 46 47 await promiseFrame(); 48 scrollEventPromise = promiseOneEvent(window, "scroll"); 49 scrollendEventPromise = promiseOneEvent(window, "scrollend"); 50 51 // Send a wheel event on the iframe again. 52 synthesizeWheel(iframe, 50, 50, scrollEvent); 53 await scrollEventPromise; 54 await scrollendEventPromise; 55 56 // Now it should be handoff-ed to the root scroller. 57 ok(window.scrollY > 0, 58 "The wheel event should have been handoff-ed to the root scroller"); 59 } 60 61 waitUntilApzStable() 62 .then(test) 63 .then(subtestDone, subtestFailed); 64 65 </script> 66 </body> 67 </html>