OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEven
t"> | 4 <link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEven
t"> |
5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/js-test.js"></script> |
6 <script> | 6 <script> |
| 7 window.jsTestIsAsync = true; |
| 8 |
7 var deltaX = 0; | 9 var deltaX = 0; |
8 var deltaY = 0; | 10 var deltaY = 0; |
9 var expectedDeltaX; | |
10 var expectedDeltaY; | |
11 | 11 |
12 var testDiv; | 12 var testDiv; |
13 function runTest() { | 13 function runTest() { |
14 // Basic checks. | 14 // Basic checks. |
15 shouldBe('WheelEvent.__proto__', 'MouseEvent'); | 15 shouldBe('WheelEvent.__proto__', 'MouseEvent'); |
16 shouldBe('WheelEvent.prototype.__proto__', 'MouseEvent.prototype'); | 16 shouldBe('WheelEvent.prototype.__proto__', 'MouseEvent.prototype'); |
17 shouldBe('WheelEvent.DOM_DELTA_PIXEL', '0x00'); | 17 shouldBe('WheelEvent.DOM_DELTA_PIXEL', '0x00'); |
18 shouldBe('WheelEvent.DOM_DELTA_LINE', '0x01'); | 18 shouldBe('WheelEvent.DOM_DELTA_LINE', '0x01'); |
19 shouldBe('WheelEvent.DOM_DELTA_PAGE', '0x02'); | 19 shouldBe('WheelEvent.DOM_DELTA_PAGE', '0x02'); |
20 | 20 |
21 testDiv = document.getElementById('target'); | 21 testDiv = document.getElementById('target'); |
22 shouldBeNull('window.onwheel'); | 22 shouldBeNull('window.onwheel'); |
23 shouldBeNull('document.onwheel'); | 23 shouldBeNull('document.onwheel'); |
24 shouldBeNull('testDiv.onwheel'); | 24 shouldBeNull('testDiv.onwheel'); |
25 testDiv.addEventListener('wheel', wheelHandler); | 25 testDiv.addEventListener('wheel', wheelHandler); |
26 if (window.eventSender) { | 26 if (window.eventSender) { |
27 eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5); | 27 eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5); |
28 eventSender.mouseScrollBy(-1, -2); | 28 eventSender.mouseScrollBy(-1, -2); |
29 expectedDeltaX = testDiv.scrollLeft; | 29 var positive = "deltaX > 0 && deltaY > 0"; |
30 expectedDeltaY = testDiv.scrollTop; | 30 var correct = "deltaX == testDiv.scrollLeft && deltaY == testDiv.scrollT
op"; |
31 shouldBeTrue("deltaX > 0"); | 31 shouldBecomeEqual(positive + " && " + correct , "true", finishJSTest); |
32 shouldBe("deltaX", "expectedDeltaX"); | |
33 shouldBeTrue("deltaY > 0"); | |
34 shouldBe("deltaY", "expectedDeltaY"); | |
35 } else { | 32 } else { |
36 debug("FAIL: This test requires window.eventSender."); | 33 debug("FAIL: This test requires window.eventSender."); |
37 } | 34 } |
38 } | 35 } |
39 | 36 |
40 var testEvent; | 37 var testEvent; |
41 function wheelHandler(e) { | 38 function wheelHandler(e) { |
42 testEvent = e; | 39 testEvent = e; |
43 shouldBe("testEvent.__proto__", "WheelEvent.prototype"); | 40 shouldBe("testEvent.__proto__", "WheelEvent.prototype"); |
44 shouldBe("testEvent.__proto__.__proto__", "MouseEvent.prototype"); | 41 shouldBe("testEvent.__proto__.__proto__", "MouseEvent.prototype"); |
(...skipping 21 matching lines...) Expand all Loading... |
66 </div> | 63 </div> |
67 </span> | 64 </span> |
68 <div id="console"></div> | 65 <div id="console"></div> |
69 <script> | 66 <script> |
70 description("Tests the basic functionality of the standard wheel event"); | 67 description("Tests the basic functionality of the standard wheel event"); |
71 | 68 |
72 runTest(); | 69 runTest(); |
73 </script> | 70 </script> |
74 </body> | 71 </body> |
75 </html> | 72 </html> |
OLD | NEW |