OLD | NEW |
---|---|
1 <html dir=rtl> | 1 <html dir=rtl> |
2 <head> | |
3 <script src="../../resources/js-test.js"></script> | |
4 <script> | |
5 | 2 |
6 function log(str) | 3 <script src="../../resources/js-test.js"></script> |
7 { | 4 <script> |
8 var li = document.createElement("li"); | 5 var testScrolls = []; |
9 li.appendChild(document.createTextNode(str)); | 6 var currentTest = -1; |
10 var console = document.getElementById("console"); | 7 window.jsTestIsAsync = true; |
11 console.appendChild(li); | |
12 } | |
13 | |
14 | 8 |
15 if (window.testRunner) { | 9 function startNextTestCase() { |
16 testRunner.waitUntilDone(); | 10 currentTest++; |
17 } | 11 if (currentTest >= testScrolls.length) { |
12 finishJSTest(); | |
13 return; | |
14 } | |
15 var testCase = testScrolls[currentTest]; | |
16 eventSender.mouseMoveTo(100, 100); | |
17 eventSender.continuousMouseScrollBy(testCase.x, testCase.y); | |
18 shouldBecomeEqual("window.scrollX == " + testCase.expectedX + " && " + | |
19 "window.scrollY == " + testCase.expectedY, "true", startNextTestCase ); | |
20 } | |
18 | 21 |
19 function dispatchWheelEvent() | 22 window.onload = function() { |
20 { | 23 if (!window.testRunner) |
21 window.addEventListener("mousewheel", mousewheelHandler, false); | 24 return; |
22 | 25 |
23 window.scrollTo(-100, 100); | 26 window.addEventListener("mousewheel", function mousewheelHandler(e){}, f alse); |
skobes
2015/11/06 22:30:23
Function name (mousewheelHandler) is not needed.
ymalik
2015/11/07 04:22:27
Done.
| |
24 if (window.eventSender) { | |
25 eventSender.mouseMoveTo(100, 100); | |
26 eventSender.continuousMouseScrollBy(-10, 0); | |
27 eventSender.continuousMouseScrollBy(30, 0); | |
28 eventSender.continuousMouseScrollBy(0, -10); | |
29 eventSender.continuousMouseScrollBy(0, 30); | |
30 } | |
31 | 27 |
32 setTimeout('checkOffsets();', 100); | 28 window.scrollTo(-100, 100); |
33 } | 29 testScrolls = [ |
skobes
2015/11/06 22:30:23
This can be moved to the declaration of testScroll
ymalik
2015/11/07 04:22:27
Done.
| |
30 {x: -10, y: 0, expectedX: -90, expectedY: 100}, | |
31 {x: 30, y: 0, expectedX: -120, expectedY: 100}, | |
32 {x: 0, y: -10, expectedX: -120, expectedY: 110}, | |
33 {x: 0, y: 30, expectedX: -120, expectedY: 80}, | |
34 ]; | |
35 startNextTestCase(); | |
36 } | |
37 </script> | |
34 | 38 |
35 function checkOffsets() | 39 <body style="margin:0"> |
36 { | 40 <div id="div" style="whitespace:nowrap; width: 4000px; height: 1000px; borde r: 1px solid red;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillu m dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proiden t, sunt in culpa qui officia deserunt mollit anim id est laborum."</div> |
37 log("window.scrollX: " + window.scrollX); | 41 <div id="console"></div> |
38 log("window.scrollY: " + window.scrollY); | 42 </body> |
39 | |
40 if (window.testRunner) | |
41 window.testRunner.notifyDone(); | |
42 } | |
43 | |
44 function mousewheelHandler(e) | |
45 { | |
46 } | |
47 </script> | |
48 </head> | |
49 | |
50 <body style="margin:0" onload="setTimeout('dispatchWheelEvent();', 100)"> | |
51 | |
52 <div id="div" style="whitespace:nowrap; width: 4000px; height: 1000px; b order: 1px solid red;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad m inim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea com modo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse c illum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non pro ident, sunt in culpa qui officia deserunt mollit anim id est laborum."</div> | |
53 <div id="console"></div> | |
54 </body> | |
55 </html> | 43 </html> |
OLD | NEW |