| <!DOCTYPE html> |
| <html> |
| <head> |
| <link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEvent"> |
| <script src="../../../resources/testharness.js"></script> |
| <script src="../../../resources/testharnessreport.js"></script> |
| <script src="../../../resources/gesture-util.js"></script> |
| </head> |
| <body> |
| <span id="parent"> |
| <div id="target" style="border:solid 1px green; width:220px; height:70px; overflow:scroll; white-space:nowrap;"> |
| TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP<br/> |
| Scroll mouse wheel over here<br/> |
| Scroll mouse wheel over here<br/> |
| Scroll mouse wheel over here<br/> |
| Scroll mouse wheel over here<br/> |
| Scroll mouse wheel over here<br/> |
| Scroll mouse wheel over here<br/> |
| END END END END END END END END END END END END END END<br/> |
| </div> |
| </span> |
| <div id="console"></div> |
| </body> |
| <script> |
| var deltaX = 0; |
| var deltaY = 0; |
| |
| promise_test(async () => { |
| // Basic checks. |
| assert_equals(WheelEvent.__proto__, MouseEvent); |
| assert_equals(WheelEvent.prototype.__proto__, MouseEvent.prototype); |
| assert_equals(WheelEvent.DOM_DELTA_PIXEL, 0x00); |
| assert_equals(WheelEvent.DOM_DELTA_LINE, 0x01); |
| assert_equals(WheelEvent.DOM_DELTA_PAGE, 0x02); |
| |
| var testDiv = document.getElementById('target'); |
| assert_equals(window.onwheel, null); |
| assert_equals(document.onwheel, null); |
| assert_equals(testDiv.onwheel, null); |
| testDiv.addEventListener('wheel', wheelHandler); |
| var x = testDiv.offsetLeft + 5; |
| var y = testDiv.offsetTop + 5; |
| await mouseMoveTo(x, y); |
| await smoothScroll(40, x, y, GestureSourceType.MOUSE_INPUT, 'downright', SPEED_INSTANT); |
| await waitFor( () => { |
| return deltaX > 0 && deltaY > 0 && deltaX == testDiv.scrollLeft && |
| deltaY == testDiv.scrollTop; |
| }); |
| }, "Tests the basic functionality of the standard wheel event"); |
| |
| var testEvent; |
| function wheelHandler(e) { |
| testEvent = e; |
| assert_equals(testEvent.__proto__, WheelEvent.prototype); |
| assert_equals(testEvent.__proto__.__proto__, MouseEvent.prototype); |
| if (e.deltaX) |
| deltaX = e.deltaX; |
| if (e.deltaY) |
| deltaY = e.deltaY; |
| assert_equals(testEvent.deltaZ, 0); |
| assert_equals(testEvent.deltaMode, WheelEvent.DOM_DELTA_PIXEL); |
| } |
| </script> |
| </html> |