wheel-event-transactions-target-move.html (2779B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/resources/testdriver.js"></script> 9 <script src="/resources/testdriver-actions.js"></script> 10 <script src="/resources/testdriver-vendor.js"></script> 11 <script src="scroll_support.js"></script> 12 <style> 13 body { 14 margin: 0; 15 padding: 0; 16 height: 200vh; 17 } 18 19 .spacer { 20 width: 100%; 21 height: 25px; 22 padding: 0; 23 margin: 0; 24 } 25 26 </style> 27 <head> 28 <body> 29 <div id="initialTarget" class="spacer" style="background: red"></div> 30 <div id="firstRootSpacer" class="spacer" style="background: green"></div> 31 <div id="secondRootSpacer" class="spacer" style="background: blue"></div> 32 </body> 33 34 <script> 35 36 promise_test(async (t) => { 37 await new Promise(resolve => addEventListener("load", resolve, {once: true})); 38 39 await waitForCompositorReady(); 40 41 await waitForCompositorCommit(); 42 43 let wheelEventTargets = []; 44 let movedInitialTarget = false; 45 46 // Move the initial element the wheel event is targetted at once we fire the 47 // first wheel event, then log the subsequent wheel event targets. 48 function moveInitialElement(e) { 49 wheelEventTargets.push(e.target); 50 if (!movedInitialTarget) { 51 movedInitialTarget = true; 52 secondRootSpacer.insertAdjacentElement('afterend', e.target); 53 } 54 } 55 window.addEventListener("wheel", moveInitialElement, {passive: true}); 56 57 await waitForCompositorCommit(); 58 59 await new test_driver.Actions() 60 .addWheel("wheel1") 61 .scroll(40, 2, 0, 30, {origin: "viewport"}) 62 .pause(1) 63 .scroll(40, 2, 0, 30, {origin: "viewport"}) 64 .send(); 65 66 // TODO(dlrobertson): Use the scrollend event here to wait for the 67 // wheel scroll to finish instead of waitForAnimationEnd(). 68 await waitForAnimationEnd(() => { return document.scrollingElement.scrollTop; }); 69 await waitForCompositorCommit(); 70 71 // The first wheel event should be targetted at the moved element. 72 assert_equals(wheelEventTargets.shift(), initialTarget, 73 "Initial wheel event has the moved element as the target"); 74 75 wheelEventTargets.forEach((wheelEventTarget, i) => { 76 // TODO(dlrobertson): This assertion is pretty weak, but browsers seem to disagree 77 // on what element the event should target. Find out what the target should be here 78 // and make this assertion more restrictive. 79 assert_not_equals(wheelEventTarget, initialTarget, 80 "Wheel event at index `" + i + "` targetted the initial element"); 81 }); 82 assert_greater_than(document.scrollingElement.scrollTop, 0, "The document has scrolled"); 83 }, "Move the initial wheel event target."); 84 </script> 85 </html>