enrica@apple.com | 13780da | 2010-03-15 20:31:04 +0000 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
mark.lam@apple.com | 436bf82 | 2013-09-07 23:07:25 +0000 | [diff] [blame] | 3 | <script src="../../resources/js-test-pre.js"></script> |
enrica@apple.com | 13780da | 2010-03-15 20:31:04 +0000 | [diff] [blame] | 4 | <script> |
| 5 | var expectedScrollTop = 200; |
| 6 | var expectedScrollLeft = 100; |
| 7 | var event; |
| 8 | var div; |
| 9 | |
rniwa@webkit.org | ada3c20 | 2012-06-20 03:28:42 +0000 | [diff] [blame] | 10 | if (window.testRunner) { |
| 11 | testRunner.waitUntilDone(); |
enrica@apple.com | 13780da | 2010-03-15 20:31:04 +0000 | [diff] [blame] | 12 | } |
| 13 | |
| 14 | function dispatchWheelEvent() |
| 15 | { |
| 16 | var overflowElement = document.getElementById("overflow"); |
| 17 | if (overflowElement) |
| 18 | overflowElement.addEventListener("mousewheel", mousewheelHandler, false); |
| 19 | |
| 20 | if (window.eventSender) { |
| 21 | eventSender.mouseMoveTo(100, 110); |
| 22 | eventSender.continuousMouseScrollBy(-window.expectedScrollLeft, -window.expectedScrollTop); |
| 23 | } |
| 24 | |
| 25 | setTimeout('checkOffsets();', 100); |
| 26 | } |
| 27 | |
| 28 | function checkOffsets() |
| 29 | { |
| 30 | div = document.getElementById("overflow"); |
| 31 | shouldBe("div.scrollTop", "window.expectedScrollTop"); |
| 32 | shouldBe("div.scrollLeft", "window.expectedScrollLeft"); |
| 33 | |
rniwa@webkit.org | ada3c20 | 2012-06-20 03:28:42 +0000 | [diff] [blame] | 34 | if (window.testRunner) |
| 35 | window.testRunner.notifyDone(); |
enrica@apple.com | 13780da | 2010-03-15 20:31:04 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | function mousewheelHandler(e) |
| 39 | { |
| 40 | event = e; |
commit-queue@webkit.org | 10fad57 | 2010-09-06 06:50:21 +0000 | [diff] [blame] | 41 | shouldBe("event.wheelDeltaY", "window.expectedScrollTop*-3"); |
| 42 | shouldBe("event.wheelDeltaX", "window.expectedScrollLeft*-3"); |
enrica@apple.com | 13780da | 2010-03-15 20:31:04 +0000 | [diff] [blame] | 43 | |
| 44 | if (e.wheelDeltaY) |
commit-queue@webkit.org | 10fad57 | 2010-09-06 06:50:21 +0000 | [diff] [blame] | 45 | shouldBe("event.wheelDelta", "window.expectedScrollTop*-3"); |
enrica@apple.com | 13780da | 2010-03-15 20:31:04 +0000 | [diff] [blame] | 46 | else |
commit-queue@webkit.org | 10fad57 | 2010-09-06 06:50:21 +0000 | [diff] [blame] | 47 | shouldBe("event.wheelDelta", "window.expectedScrollLeft*-3"); |
enrica@apple.com | 13780da | 2010-03-15 20:31:04 +0000 | [diff] [blame] | 48 | } |
| 49 | </script> |
| 50 | </head> |
| 51 | |
| 52 | <body style="margin:0" onload="setTimeout('dispatchWheelEvent();', 100)"> |
| 53 | <div id="overflow" style="border:2px solid black;overflow:auto;height:200px;width:200px;"> |
| 54 | <div style="background-color:red;height:200px;width:400px;"></div> |
| 55 | <div style="background-color:green;height:200px;width:400px;"></div> |
| 56 | <div style="background-color:red;height:200px;width:400px;"></div> |
| 57 | </div> |
| 58 | <div id="console"></div> |
| 59 | </body> |
| 60 | </html> |