| 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 isMacOSX = navigator.userAgent.indexOf("Mac OS X") >= 0; | 6 var isMacOSX = navigator.userAgent.indexOf("Mac OS X") >= 0; |
| 6 | 7 |
| 7 var givenScrollTop = 2; // Only one page per event, so this should b
e interpreted as 1 | 8 var givenScrollTop = 2; // Only one page per event, so this should b
e interpreted as 1 |
| 8 var givenScrollLeft = 2; | 9 var givenScrollLeft = 2; |
| 9 | 10 |
| 10 var maxOverlapBetweenPages = 40; | 11 var maxOverlapBetweenPages = 40; |
| 11 | 12 |
| 12 // Window is 800x600. Page scrolls 87.5% of window size. | 13 // Window is 800x600. Page scrolls 87.5% of window size. |
| 13 var expectedScrollTop = 600 * 0.875; | 14 var expectedScrollTop = 600 * 0.875; |
| 14 var expectedScrollLeft = 800 * 0.875; | 15 var expectedScrollLeft = 800 * 0.875; |
| 15 | 16 |
| 16 if (isMacOSX) { | 17 if (isMacOSX) { |
| 17 // On Mac, there is a max overlap between pages that can affect
the page scroll size. | 18 // On Mac, there is a max overlap between pages that can affect
the page scroll size. |
| 18 expectedScrollTop = Math.max(expectedScrollTop, 600 - maxOverlap
BetweenPages); | 19 expectedScrollTop = Math.max(expectedScrollTop, 600 - maxOverlap
BetweenPages); |
| 19 expectedScrollLeft = Math.max(expectedScrollLeft, 800 - maxOverl
apBetweenPages); | 20 expectedScrollLeft = Math.max(expectedScrollLeft, 800 - maxOverl
apBetweenPages); |
| 20 } | 21 } |
| 21 | 22 |
| 22 var event; | 23 var event; |
| 23 var div; | 24 var div; |
| 24 | 25 |
| 25 window.jsTestIsAsync = true; | 26 function runTest() |
| 26 if (window.testRunner) | |
| 27 testRunner.waitUntilDone(); | |
| 28 | |
| 29 function dispatchWheelEvent() | |
| 30 { | 27 { |
| 31 document.body.addEventListener("mousewheel", mousewheelHandler,
false); | 28 document.body.addEventListener("mousewheel", mousewheelHandler,
false); |
| 32 | 29 |
| 33 if (window.eventSender) { | 30 if (window.eventSender) { |
| 34 eventSender.mouseMoveTo(100, 110); | 31 eventSender.mouseMoveTo(100, 110); |
| 35 eventSender.continuousMouseScrollBy(-window.givenScrollLeft,
-window.givenScrollTop, true); | 32 eventSender.continuousMouseScrollBy(-window.givenScrollLeft,
-window.givenScrollTop, true); |
| 36 } | 33 } |
| 37 | 34 |
| 38 setTimeout('checkOffsets();', 100); | 35 shouldBecomeEqual("document.scrollingElement.scrollTop == window
.expectedScrollTop && " + |
| 39 } | 36 "document.scrollingElement.scrollLeft == window.expectedScro
llLeft", "true", finishJSTest) |
| 40 | |
| 41 function checkOffsets() | |
| 42 { | |
| 43 shouldBe("document.scrollingElement.scrollTop", "window.expected
ScrollTop"); | |
| 44 shouldBe("document.scrollingElement.scrollLeft", "window.expecte
dScrollLeft"); | |
| 45 finishJSTest(); | |
| 46 } | 37 } |
| 47 | 38 |
| 48 function mousewheelHandler(e) | 39 function mousewheelHandler(e) |
| 49 { | 40 { |
| 50 event = e; | 41 event = e; |
| 51 shouldBe("event.wheelDeltaY", "window.givenScrollTop * -3"); | 42 shouldBe("event.wheelDeltaY", "window.givenScrollTop * -3"); |
| 52 shouldBe("event.wheelDeltaX", "window.givenScrollLeft * -3"); | 43 shouldBe("event.wheelDeltaX", "window.givenScrollLeft * -3"); |
| 53 | 44 |
| 54 if (e.wheelDeltaY) | 45 if (e.wheelDeltaY) |
| 55 shouldBe("event.wheelDelta", "window.givenScrollTop * -3"); | 46 shouldBe("event.wheelDelta", "window.givenScrollTop * -3"); |
| 56 else | 47 else |
| 57 shouldBe("event.wheelDelta", "window.givenScrollLeft * -3"); | 48 shouldBe("event.wheelDelta", "window.givenScrollLeft * -3"); |
| 58 } | 49 } |
| 59 </script> | 50 </script> |
| 60 </head> | 51 </head> |
| 61 | 52 |
| 62 <body style="margin:0" onload="setTimeout('dispatchWheelEvent();', 100)"> | 53 <body style="margin:0" onload="runTest()"> |
| 63 <div style="height:900px;width:2400px"> | 54 <div style="height:900px;width:2400px"> |
| 64 <div style="background-color:red;height:900px;width:1200px;position:re
lative;left:0px;top:0px"></div> | 55 <div style="background-color:red;height:900px;width:1200px;position:re
lative;left:0px;top:0px"></div> |
| 65 <div style="background-color:green;height:900px;width:1200px;position:
relative;left:1200px;top:-900px"></div> | 56 <div style="background-color:green;height:900px;width:1200px;position:
relative;left:1200px;top:-900px"></div> |
| 66 </div> | 57 </div> |
| 67 <div style="height:900px;width:2400px"> | 58 <div style="height:900px;width:2400px"> |
| 68 <div style="background-color:blue;height:900px;width:1200px;position:r
elative;left:0px;top:0px"></div> | 59 <div style="background-color:blue;height:900px;width:1200px;position:r
elative;left:0px;top:0px"></div> |
| 69 <div style="background-color:yellow;height:900px;width:1200px;position
:relative;left:1200px;top:-900px"></div> | 60 <div style="background-color:yellow;height:900px;width:1200px;position
:relative;left:1200px;top:-900px"></div> |
| 70 </div> | 61 </div> |
| 71 <div id="console"></div> | 62 <div id="console"></div> |
| 72 </body> | 63 </body> |
| 73 </html> | 64 </html> |
| OLD | NEW |