| <!DOCTYPE html> |
| <script src='../../resources/gesture-util.js'></script> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <div id="overflow" style="border:2px solid black;overflow:auto;height:200px;width:200px;"> |
| <div style="background-color:red;height:200px;width:400px;"></div> |
| <div style="background-color:green;height:200px;width:400px;"></div> |
| <div style="background-color:red;height:200px;width:400px;"></div> |
| </div> |
| |
| <script> |
| |
| var expectedScrollTop = 200; |
| var expectedScrollLeft = 100; |
| var last_event = null; |
| var source = GestureSourceType.MOUSE_INPUT; |
| const numTicksX = expectedScrollLeft / pixelsPerTick(); |
| const numTicksY = expectedScrollTop / pixelsPerTick(); |
| const expectedWheelDeltaX = numTicksX * LEGACY_MOUSE_WHEEL_TICK_MULTIPLIER; |
| const expectedWheelDeltaY = numTicksY * LEGACY_MOUSE_WHEEL_TICK_MULTIPLIER; |
| |
| function mousewheelHandler(e) |
| { |
| last_event = e; |
| } |
| |
| promise_test(async () => { |
| var overflowElement = document.getElementById("overflow"); |
| overflowElement.addEventListener("mousewheel", mousewheelHandler, false); |
| |
| await smoothScroll(window.expectedScrollLeft, 100, 110, source, 'right', SPEED_INSTANT); |
| await waitFor( () => { |
| return overflowElement.scrollLeft == window.expectedScrollLeft; |
| }); |
| assert_equals(last_event.wheelDeltaX, -Math.floor(expectedWheelDeltaX)); |
| assert_equals(last_event.wheelDelta, -Math.floor(expectedWheelDeltaX)); |
| last_event = null; |
| |
| await smoothScroll(window.expectedScrollTop, 100, 110, source, 'down', SPEED_INSTANT); |
| await waitFor( () => { |
| return overflowElement.scrollTop == window.expectedScrollTop; |
| }); |
| assert_equals(last_event.wheelDeltaY, -Math.floor(expectedWheelDeltaY)); |
| assert_equals(last_event.wheelDelta, -Math.floor(expectedWheelDeltaY)); |
| }, 'This test checks the wheel delta value of wheel events, which should be the number of ticks multiplies the legacy mouse wheel tick multiplier.'); |
| |
| </script> |