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 deltaX = window.expectedScrollLeft; | 19 // EventSender uses 40px per tick. |
20 var deltaY = window.expectedScrollTop; | 20 eventSender.mouseMoveTo(overflowElement.offsetLeft + 5, over
flowElement.offsetTop + 5); |
21 var eventInit = { | 21 eventSender.mouseScrollBy(-2.5, -5); |
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); | |
29 } | 22 } |
30 | 23 |
31 setTimeout('checkOffsets();', 100); | 24 setTimeout('checkOffsets();', 100); |
32 } | 25 } |
33 | 26 |
34 function checkOffsets() | 27 function checkOffsets() |
35 { | 28 { |
36 div = document.getElementById("overflow"); | 29 div = document.getElementById("overflow"); |
37 shouldBe("div.scrollTop", "window.expectedScrollTop"); | 30 shouldBe("div.scrollTop", "window.expectedScrollTop"); |
38 shouldBe("div.scrollLeft", "window.expectedScrollLeft"); | 31 shouldBe("div.scrollLeft", "window.expectedScrollLeft"); |
39 | 32 |
40 if (window.testRunner) | 33 if (window.testRunner) |
41 window.testRunner.notifyDone(); | 34 window.testRunner.notifyDone(); |
42 } | 35 } |
43 | 36 |
44 function mousewheelHandler(e) | 37 function mousewheelHandler(e) |
45 { | 38 { |
46 event = e; | 39 event = e; |
47 shouldBe("event.deltaY", "window.expectedScrollTop"); | 40 shouldBe("event.deltaY", "window.expectedScrollTop"); |
48 shouldBe("event.deltaX", "window.expectedScrollLeft"); | 41 shouldBe("event.deltaX", "window.expectedScrollLeft"); |
49 shouldBe("event.wheelDeltaY", "window.expectedScrollTop*-120"); | 42 shouldBe("event.wheelDeltaY", "-5*120"); |
50 shouldBe("event.wheelDeltaX", "window.expectedScrollLeft*-120"); | 43 shouldBe("event.wheelDeltaX", "-2.5*120"); |
51 | 44 |
52 if (e.wheelDeltaY) | 45 if (e.wheelDeltaY) |
53 shouldBe("event.wheelDelta", "window.expectedScrollTop*-120"
); | 46 shouldBe("event.wheelDelta", "-5*120"); |
54 else | 47 else |
55 shouldBe("event.wheelDelta", "window.expectedScrollLeft*-120
"); | 48 shouldBe("event.wheelDelta", "-2.5*120"); |
56 } | 49 } |
57 </script> | 50 </script> |
58 </head> | 51 </head> |
59 | 52 |
60 <body style="margin:0" onload="setTimeout('dispatchWheelEvent();', 100)"> | 53 <body style="margin:0" onload="setTimeout('dispatchWheelEvent();', 100)"> |
61 <div id="overflow" style="border:2px solid black;overflow:auto;height:20
0px;width:200px;"> | 54 <div id="overflow" style="border:2px solid black;overflow:auto;height:20
0px;width:200px;"> |
62 <div style="background-color:red;height:200px;width:400px;"></div> | 55 <div style="background-color:red;height:200px;width:400px;"></div> |
63 <div style="background-color:green;height:200px;width:400px;"></div> | 56 <div style="background-color:green;height:200px;width:400px;"></div> |
64 <div style="background-color:red;height:200px;width:400px;"></div> | 57 <div style="background-color:red;height:200px;width:400px;"></div> |
65 </div> | 58 </div> |
66 <div id="console"></div> | 59 <div id="console"></div> |
67 </body> | 60 </body> |
68 </html> | 61 </html> |
OLD | NEW |