ch.dumez@sisa.samsung.com | 181483e | 2013-08-27 10:09:06 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEvent"> |
mark.lam@apple.com | 436bf82 | 2013-09-07 23:07:25 +0000 | [diff] [blame] | 5 | <script src="../../resources/js-test-pre.js"></script> |
ch.dumez@sisa.samsung.com | 181483e | 2013-08-27 10:09:06 +0000 | [diff] [blame] | 6 | <script> |
ap@apple.com | 8c45cee | 2015-08-21 23:09:54 +0000 | [diff] [blame] | 7 | var eventDeltaX = 0; |
| 8 | var eventDeltaY = 0; |
| 9 | var scrollDeltaX; |
| 10 | var scrollDeltaY; |
| 11 | |
| 12 | jsTestIsAsync = true; |
ch.dumez@sisa.samsung.com | 181483e | 2013-08-27 10:09:06 +0000 | [diff] [blame] | 13 | |
| 14 | var testDiv; |
| 15 | function runTest() { |
| 16 | // Basic checks. |
| 17 | shouldBe('WheelEvent.prototype.__proto__', 'MouseEvent.prototype'); |
| 18 | shouldBe('WheelEvent.DOM_DELTA_PIXEL', '0x00'); |
| 19 | shouldBe('WheelEvent.DOM_DELTA_LINE', '0x01'); |
| 20 | shouldBe('WheelEvent.DOM_DELTA_PAGE', '0x02'); |
| 21 | |
| 22 | testDiv = document.getElementById('target'); |
| 23 | shouldBeNull('window.onwheel'); |
| 24 | shouldBeNull('document.onwheel'); |
| 25 | shouldBeNull('testDiv.onwheel'); |
| 26 | testDiv.addEventListener('wheel', wheelHandler); |
| 27 | if (window.eventSender) { |
| 28 | eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5); |
| 29 | eventSender.mouseScrollBy(-1, -2); |
ch.dumez@sisa.samsung.com | 181483e | 2013-08-27 10:09:06 +0000 | [diff] [blame] | 30 | } else { |
| 31 | debug("FAIL: This test requires window.eventSender."); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | var testEvent; |
| 36 | function wheelHandler(e) { |
ap@apple.com | 8c45cee | 2015-08-21 23:09:54 +0000 | [diff] [blame] | 37 | debug("Wheel event fired"); |
ch.dumez@sisa.samsung.com | 181483e | 2013-08-27 10:09:06 +0000 | [diff] [blame] | 38 | testEvent = e; |
| 39 | shouldBe("testEvent.__proto__", "WheelEvent.prototype"); |
| 40 | shouldBe("testEvent.__proto__.__proto__", "MouseEvent.prototype"); |
ap@apple.com | 8c45cee | 2015-08-21 23:09:54 +0000 | [diff] [blame] | 41 | shouldBeTrue("testEvent.deltaX > 0"); |
| 42 | shouldBeTrue("testEvent.deltaY > 0"); |
ch.dumez@sisa.samsung.com | 181483e | 2013-08-27 10:09:06 +0000 | [diff] [blame] | 43 | shouldBe("testEvent.deltaZ", "0"); |
| 44 | shouldBe("testEvent.deltaMode", "WheelEvent.DOM_DELTA_PIXEL") |
ap@apple.com | 8c45cee | 2015-08-21 23:09:54 +0000 | [diff] [blame] | 45 | eventDeltaX = e.deltaX; |
| 46 | eventDeltaY = e.deltaY; |
| 47 | } |
| 48 | |
| 49 | function scrollHandler() |
| 50 | { |
| 51 | debug("Scroll event fired"); |
| 52 | scrollDeltaX = testDiv.scrollLeft; |
| 53 | scrollDeltaY = testDiv.scrollTop; |
| 54 | shouldBe("eventDeltaX", "scrollDeltaX"); |
| 55 | shouldBe("eventDeltaY", "scrollDeltaY"); |
| 56 | |
| 57 | finishJSTest(); |
ch.dumez@sisa.samsung.com | 181483e | 2013-08-27 10:09:06 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | </script> |
| 61 | </head> |
| 62 | <body> |
| 63 | <span id="parent"> |
ap@apple.com | 8c45cee | 2015-08-21 23:09:54 +0000 | [diff] [blame] | 64 | <div id="target" style="border:solid 1px green; width:100px; height:70px; overflow:scroll; white-space:nowrap;" onscroll="scrollHandler()"> |
ch.dumez@sisa.samsung.com | 181483e | 2013-08-27 10:09:06 +0000 | [diff] [blame] | 65 | TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP<br/> |
| 66 | Scroll mouse wheel over here<br/> |
| 67 | Scroll mouse wheel over here<br/> |
| 68 | Scroll mouse wheel over here<br/> |
| 69 | Scroll mouse wheel over here<br/> |
| 70 | Scroll mouse wheel over here<br/> |
| 71 | Scroll mouse wheel over here<br/> |
| 72 | END END END END END END END END END END END END END END<br/> |
| 73 | </div> |
| 74 | </span> |
| 75 | <div id="console"></div> |
| 76 | <script> |
| 77 | description("Tests the basic functionality of the standard wheel event"); |
| 78 | |
| 79 | runTest(); |
| 80 | </script> |
mark.lam@apple.com | 436bf82 | 2013-09-07 23:07:25 +0000 | [diff] [blame] | 81 | <script src="../../resources/js-test-post.js"></script> |
ch.dumez@sisa.samsung.com | 181483e | 2013-08-27 10:09:06 +0000 | [diff] [blame] | 82 | </body> |
| 83 | </html> |