OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../resources/js-test.js"></script> | 2 <script src="../../resources/js-test.js"></script> |
3 <div style="margin: 0px 0; width: 100px; height: 1000px; background-color: blue; "></div> | 3 <div style="margin: 0px 0; width: 100px; height: 1000px; background-color: blue; "></div> |
4 <script> | 4 <script> |
5 window.jsTestIsAsync = true; | 5 window.jsTestIsAsync = true; |
6 | 6 |
7 function testVerticalScroll() { | 7 function testVerticalScroll() { |
8 // Do a purely vertical scroll. This will scroll contents only. | 8 // Do a purely vertical scroll. This will scroll contents only. |
9 eventSender.continuousMouseScrollBy(0, -1); | 9 eventSender.continuousMouseScrollBy(0, -2, false, true); |
bokan
2016/03/17 12:31:16
Why do we need the arguments on only this call?
dtapuska
2016/03/17 12:48:11
Because I accidentally left them in from debugging
| |
10 shouldBecomeEqual('internals.visualViewportScrollX() == 200 && ' + | 10 shouldBecomeEqual('internals.visualViewportScrollX() == 200 && ' + |
11 'internals.visualViewportScrollY() == 301', 'true', testHorizontalScroll); | 11 'internals.visualViewportScrollY() == 301', 'true', testHorizontalScroll); |
12 } | 12 } |
13 | 13 |
14 function testHorizontalScroll() { | 14 function testHorizontalScroll() { |
15 // Do a purely horizontal scroll. This will change pinch virtual viewport | 15 // Do a purely horizontal scroll. This will change pinch virtual viewport |
16 // offset only. | 16 // offset only. |
17 eventSender.continuousMouseScrollBy(-1, 0); | 17 eventSender.continuousMouseScrollBy(-2, 0); |
18 shouldBecomeEqual('internals.visualViewportScrollX() == 201 && ' + | 18 shouldBecomeEqual('internals.visualViewportScrollX() == 201 && ' + |
19 'internals.visualViewportScrollY() == 301', 'true', testDiagonalScroll); | 19 'internals.visualViewportScrollY() == 301', 'true', testDiagonalScroll); |
20 } | 20 } |
21 | 21 |
22 function testDiagonalScroll() { | 22 function testDiagonalScroll() { |
23 // Do a diagonal scroll. This will scroll the contents, and then bubble the | 23 // Do a diagonal scroll. This will scroll the contents, and then bubble the |
24 // result up to the visual viewport, where it will change the pinch | 24 // result up to the visual viewport, where it will change the pinch |
25 // virtual viewport offset. | 25 // virtual viewport offset. |
26 eventSender.continuousMouseScrollBy(2, 2); | 26 eventSender.continuousMouseScrollBy(4, 4); |
27 shouldBecomeEqual('internals.visualViewportScrollX() == 199 && ' + | 27 shouldBecomeEqual('internals.visualViewportScrollX() == 199 && ' + |
28 'internals.visualViewportScrollY() == 299', 'true', finishJSTest); | 28 'internals.visualViewportScrollY() == 299', 'true', finishJSTest); |
29 } | 29 } |
30 | 30 |
31 // TODO: This test just verifies that scrollX and scrollY end up with the right | 31 // TODO: This test just verifies that scrollX and scrollY end up with the right |
32 // values after a scroll. It does not verify whether these values are coming | 32 // values after a scroll. It does not verify whether these values are coming |
33 // from content scroll or from viewport moving. This should be added. | 33 // from content scroll or from viewport moving. This should be added. |
34 if (window.eventSender && window.internals) { | 34 if (window.eventSender && window.internals) { |
35 // Do a pinch at the bottom of the page. | 35 // Do a pinch at the bottom of the page. |
36 eventSender.gesturePinchBegin('touchpad', 400, 600); | 36 eventSender.gesturePinchBegin('touchpad', 400, 600); |
37 eventSender.gesturePinchUpdate('touchpad', 400, 600, 2.0); | 37 eventSender.gesturePinchUpdate('touchpad', 400, 600, 2.0); |
38 eventSender.gesturePinchEnd('touchpad', 400, 600); | 38 eventSender.gesturePinchEnd('touchpad', 400, 600); |
39 shouldBe('internals.visualViewportWidth()', '400'); | 39 shouldBe('internals.visualViewportWidth()', '400'); |
40 shouldBe('internals.visualViewportHeight()', '300'); | 40 shouldBe('internals.visualViewportHeight()', '300'); |
41 shouldBe('internals.visualViewportScrollX()', '200'); | 41 shouldBe('internals.visualViewportScrollX()', '200'); |
42 shouldBe('internals.visualViewportScrollY()', '300'); | 42 shouldBe('internals.visualViewportScrollY()', '300'); |
43 | 43 |
44 testVerticalScroll(); | 44 testVerticalScroll(); |
45 } else { | 45 } else { |
46 testFailed("This test requires the event sender and internals"); | 46 testFailed("This test requires the event sender and internals"); |
47 finishJSTest(); | 47 finishJSTest(); |
48 } | 48 } |
49 </script> | 49 </script> |
OLD | NEW |