OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
4 <script> | 4 <script> |
5 var expectedScrollTop = 200; | 5 var expectedScrollTop = 200; |
6 var expectedScrollLeft = 100; | 6 var expectedScrollLeft = 100; |
7 var event; | 7 var event; |
8 var div; | 8 var div; |
9 | 9 |
10 if (window.testRunner) | 10 if (window.testRunner) |
11 testRunner.waitUntilDone(); | 11 testRunner.waitUntilDone(); |
12 | 12 |
13 function dispatchWheelEvent() | 13 function dispatchWheelEvent() |
14 { | 14 { |
15 var overflowElement = document.getElementById("overflow"); | 15 var overflowElement = document.getElementById("overflow"); |
16 if (overflowElement) { | 16 if (overflowElement) { |
17 overflowElement.addEventListener("mousewheel", mousewheelHan
dler, false); | 17 overflowElement.addEventListener("mousewheel", mousewheelHan
dler, false); |
18 | 18 |
19 var wheelEvent = document.createEvent("WheelEvent"); | 19 var deltaX = window.expectedScrollLeft; |
20 wheelEvent.initWebKitWheelEvent(-window.expectedScrollLeft,
-window.expectedScrollTop, window, 0, 0, 0, 0, false, false, false, false); | 20 var deltaY = window.expectedScrollTop; |
21 overflowElement.dispatchEvent(wheelEvent); | 21 var eventInit = { |
| 22 deltaX: deltaX, |
| 23 deltaY: deltaY, |
| 24 wheelDeltaX: -120 * deltaX, |
| 25 wheelDeltaY: -120 * deltaY, |
| 26 }; |
| 27 var event = new WheelEvent("mousewheel", eventInit); |
| 28 overflowElement.dispatchEvent(event); |
22 } | 29 } |
23 | 30 |
24 setTimeout('checkOffsets();', 100); | 31 setTimeout('checkOffsets();', 100); |
25 } | 32 } |
26 | 33 |
27 function checkOffsets() | 34 function checkOffsets() |
28 { | 35 { |
29 div = document.getElementById("overflow"); | 36 div = document.getElementById("overflow"); |
30 shouldBe("div.scrollTop", "window.expectedScrollTop"); | 37 shouldBe("div.scrollTop", "window.expectedScrollTop"); |
31 shouldBe("div.scrollLeft", "window.expectedScrollLeft"); | 38 shouldBe("div.scrollLeft", "window.expectedScrollLeft"); |
32 | 39 |
33 if (window.testRunner) | 40 if (window.testRunner) |
34 window.testRunner.notifyDone(); | 41 window.testRunner.notifyDone(); |
35 } | 42 } |
36 | 43 |
37 function mousewheelHandler(e) | 44 function mousewheelHandler(e) |
38 { | 45 { |
39 event = e; | 46 event = e; |
| 47 shouldBe("event.deltaY", "window.expectedScrollTop"); |
| 48 shouldBe("event.deltaX", "window.expectedScrollLeft"); |
40 shouldBe("event.wheelDeltaY", "window.expectedScrollTop*-120"); | 49 shouldBe("event.wheelDeltaY", "window.expectedScrollTop*-120"); |
41 shouldBe("event.wheelDeltaX", "window.expectedScrollLeft*-120"); | 50 shouldBe("event.wheelDeltaX", "window.expectedScrollLeft*-120"); |
42 | 51 |
43 if (e.wheelDeltaY) | 52 if (e.wheelDeltaY) |
44 shouldBe("event.wheelDelta", "window.expectedScrollTop*-120"
); | 53 shouldBe("event.wheelDelta", "window.expectedScrollTop*-120"
); |
45 else | 54 else |
46 shouldBe("event.wheelDelta", "window.expectedScrollLeft*-120
"); | 55 shouldBe("event.wheelDelta", "window.expectedScrollLeft*-120
"); |
47 } | 56 } |
48 </script> | 57 </script> |
49 </head> | 58 </head> |
50 | 59 |
51 <body style="margin:0" onload="setTimeout('dispatchWheelEvent();', 100)"> | 60 <body style="margin:0" onload="setTimeout('dispatchWheelEvent();', 100)"> |
52 <div id="overflow" style="border:2px solid black;overflow:auto;height:20
0px;width:200px;"> | 61 <div id="overflow" style="border:2px solid black;overflow:auto;height:20
0px;width:200px;"> |
53 <div style="background-color:red;height:200px;width:400px;"></div> | 62 <div style="background-color:red;height:200px;width:400px;"></div> |
54 <div style="background-color:green;height:200px;width:400px;"></div> | 63 <div style="background-color:green;height:200px;width:400px;"></div> |
55 <div style="background-color:red;height:200px;width:400px;"></div> | 64 <div style="background-color:red;height:200px;width:400px;"></div> |
56 </div> | 65 </div> |
57 <div id="console"></div> | 66 <div id="console"></div> |
58 </body> | 67 </body> |
59 </html> | 68 </html> |
OLD | NEW |