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 window.jsTestIsAsync = true; |
5 var givenScrollTop = 2; // Only page is scrolled per event, regardle
ss of this number. | 6 var givenScrollTop = 2; // Only page is scrolled per event, regardle
ss of this number. |
6 var givenScrollLeft = 0; | 7 var givenScrollLeft = 0; |
7 var expectedScrollTop = 525; // Window is 800x600. Scroll 87.5% of v
isible. | 8 var expectedScrollTop = 525; // Window is 800x600. Scroll 87.5% of v
isible. |
8 var expectedScrollLeft = 0; | 9 var expectedScrollLeft = 0; |
9 var event; | 10 var event; |
10 var div; | 11 var div; |
11 | 12 |
12 window.jsTestIsAsync = true; | 13 function runTest() |
13 if (window.testRunner) | |
14 testRunner.waitUntilDone(); | |
15 | |
16 function dispatchWheelEvent() | |
17 { | 14 { |
18 document.body.addEventListener("mousewheel", mousewheelHandler,
false); | 15 document.body.addEventListener("mousewheel", mousewheelHandler,
false); |
19 | 16 |
20 if (window.eventSender) { | 17 if (window.eventSender) { |
21 eventSender.mouseMoveTo(100, 110); | 18 eventSender.mouseMoveTo(100, 110); |
22 eventSender.continuousMouseScrollBy(-window.givenScrollLeft,
-window.givenScrollTop, true); | 19 eventSender.continuousMouseScrollBy(-window.givenScrollLeft,
-window.givenScrollTop, true); |
23 } | 20 } |
24 | 21 |
25 setTimeout('checkOffsets();', 100); | 22 // This test expects failure on mac: crbug.com/552694. |
26 } | 23 shouldBecomeEqual("document.scrollingElement.scrollTop == window
.expectedScrollTop && " + |
27 | 24 "document.scrollingElement.scrollLeft == window.expectedScro
llLeft", "true", finishJSTest); |
28 function checkOffsets() | |
29 { | |
30 shouldBe("document.scrollingElement.scrollTop", "window.expected
ScrollTop"); | |
31 shouldBe("document.scrollingElement.scrollLeft", "window.expecte
dScrollLeft"); | |
32 finishJSTest(); | |
33 } | 25 } |
34 | 26 |
35 function mousewheelHandler(e) | 27 function mousewheelHandler(e) |
36 { | 28 { |
37 event = e; | 29 event = e; |
38 shouldBe("event.wheelDeltaY", "window.givenScrollTop * -3"); | 30 shouldBe("event.wheelDeltaY", "window.givenScrollTop * -3"); |
39 shouldBe("event.wheelDeltaX", "0"); | 31 shouldBe("event.wheelDeltaX", "0"); |
40 | 32 |
41 if (e.wheelDeltaY) | 33 if (e.wheelDeltaY) |
42 shouldBe("event.wheelDelta", "window.givenScrollTop * -3"); | 34 shouldBe("event.wheelDelta", "window.givenScrollTop * -3"); |
43 else | 35 else |
44 shouldBe("event.wheelDelta", "0"); | 36 shouldBe("event.wheelDelta", "0"); |
45 } | 37 } |
46 </script> | 38 </script> |
47 </head> | 39 </head> |
48 | 40 |
49 <body style="margin:0" onload="setTimeout('dispatchWheelEvent();', 100)"> | 41 <body style="margin:0" onload="runTest()"> |
50 <div style="height:900px;width:400px"> | 42 <div style="height:900px;width:400px"> |
51 <div style="background-color:red;height:900px;width:200px;position:rel
ative;left:0px;top:0px"></div> | 43 <div style="background-color:red;height:900px;width:200px;position:rel
ative;left:0px;top:0px"></div> |
52 <div style="background-color:green;height:900px;width:200px;position:r
elative;left:200px;top:-900px"></div> | 44 <div style="background-color:green;height:900px;width:200px;position:r
elative;left:200px;top:-900px"></div> |
53 </div> | 45 </div> |
54 <div style="height:900px;width:400px"> | 46 <div style="height:900px;width:400px"> |
55 <div style="background-color:blue;height:900px;width:200px;position:re
lative;left:0px;top:0px"></div> | 47 <div style="background-color:blue;height:900px;width:200px;position:re
lative;left:0px;top:0px"></div> |
56 <div style="background-color:yellow;height:900px;width:200px;position:
relative;left:200px;top:-900px"></div> | 48 <div style="background-color:yellow;height:900px;width:200px;position:
relative;left:200px;top:-900px"></div> |
57 </div> | 49 </div> |
58 <div id="console"></div> | 50 <div id="console"></div> |
59 </body> | 51 </body> |
60 </html> | 52 </html> |
OLD | NEW |