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 <script> | 3 <script> |
4 var numScrolls; | 4 var numScrolls; |
5 var pageHeight = 2000; | 5 var pageHeight = 2000; |
6 var pageWidth = 2000; | 6 var pageWidth = 2000; |
7 | 7 |
8 function reset() | 8 function reset() |
9 { | 9 { |
10 window.scrollTo(0, 0); | 10 window.scrollTo(0, 0); |
11 internals.setPageScaleFactor(2); | 11 internals.setPageScaleFactor(2); |
12 } | 12 } |
13 | 13 |
14 // Test Document scroll seperately so we ensure it scrolls all the way in one | 14 // Test Document scroll seperately so we ensure it scrolls all the way in one |
15 // shot. | 15 // shot. |
16 function testDocumentScroll() { | 16 function testDocumentScroll() { |
17 internals.executeCommand(document, 'ScrollToEndOfDocument', ''); | 17 internals.executeCommand(document, 'ScrollToEndOfDocument', ''); |
18 shouldBe('window.scrollY', 'pageHeight - window.innerHeight'); | 18 shouldBe('window.scrollY', 'pageHeight - window.innerHeight'); |
19 shouldBe('window.scrollX', '0'); | 19 shouldBe('window.scrollX', '0'); |
20 | 20 |
21 internals.executeCommand(document, 'ScrollToBeginningOfDocument', ''); | 21 internals.executeCommand(document, 'ScrollToBeginningOfDocument', ''); |
22 shouldBe('window.scrollY', '0'); | 22 shouldBe('window.scrollY', '0'); |
23 shouldBe('window.scrollX', '0'); | 23 shouldBe('window.scrollX', '0'); |
24 } | 24 } |
25 | 25 |
26 function testScroll(forwardCmd, backwardCmd) { | 26 function testScroll(forwardCmd, backwardCmd) { |
27 internals.executeCommand(document, forwardCmd, ''); | 27 internals.executeCommand(document, forwardCmd, ''); |
28 | 28 |
29 if (window.scrollY === 0) { | 29 if (internals.visualViewportScrollY() === 0) { |
30 debug('FAIL: Command ' + forwardCmd + ' failed to scroll page at all.'); | 30 debug('FAIL: Command ' + forwardCmd + ' failed to scroll page at all.'); |
31 return; | 31 return; |
32 } | 32 } |
33 | 33 |
34 numScrolls = Math.ceil((pageHeight - window.innerHeight) / window.scrollY); | 34 numScrolls = Math.ceil((pageHeight - internals.visualViewportHeight()) / int
ernals.visualViewportScrollY()); |
35 | 35 |
36 for(var i = 0; i < numScrolls - 1; ++i) { | 36 for(var i = 0; i < numScrolls - 1; ++i) { |
37 internals.executeCommand(document, forwardCmd, ''); | 37 internals.executeCommand(document, forwardCmd, ''); |
38 } | 38 } |
39 | 39 |
40 shouldBe('window.scrollY', 'pageHeight - window.innerHeight'); | 40 shouldBe('internals.visualViewportScrollY()', 'pageHeight - internals.visual
ViewportHeight()'); |
41 shouldBe('window.scrollX', '0'); | 41 shouldBe('internals.visualViewportScrollX()', '0'); |
42 | 42 |
43 for(var i = 0; i < numScrolls; ++i) { | 43 for(var i = 0; i < numScrolls; ++i) { |
44 internals.executeCommand(document, backwardCmd, ''); | 44 internals.executeCommand(document, backwardCmd, ''); |
45 } | 45 } |
46 | 46 |
47 shouldBe('window.scrollY', '0'); | 47 shouldBe('internals.visualViewportScrollY()', '0'); |
48 shouldBe('window.scrollX', '0'); | 48 shouldBe('internals.visualViewportScrollX()', '0'); |
49 } | 49 } |
50 | 50 |
51 function runTest() | 51 function runTest() |
52 { | 52 { |
53 description( | 53 description( |
54 'Test that scrolling editor commands while pinch-zoomed scrolls ' + | 54 'Test that scrolling editor commands while pinch-zoomed scrolls ' + |
55 'both viewports. To test manually, pinch zoom into the page and ' + | 55 'both viewports. To test manually, pinch zoom into the page and ' + |
56 'use the arrow keys, page up/down, home/end to scroll the page. ' + | 56 'use the arrow keys, page up/down, home/end to scroll the page. ' + |
57 'You should be able to reach the end of the page bounds (i.e. ' + | 57 'You should be able to reach the end of the page bounds (i.e. ' + |
58 'scroll to see the divs at the bounds.)'); | 58 'scroll to see the divs at the bounds.)'); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 left: 1800px; | 127 left: 1800px; |
128 } | 128 } |
129 </style> | 129 </style> |
130 <p id="description" style="width: 800px"></p> | 130 <p id="description" style="width: 800px"></p> |
131 <p id="console" style="width: 800px"></p> | 131 <p id="console" style="width: 800px"></p> |
132 <div class="top">Top of page</div> | 132 <div class="top">Top of page</div> |
133 <div class="bottom">Bottom of page</div> | 133 <div class="bottom">Bottom of page</div> |
134 <div class="left">Left of page</div> | 134 <div class="left">Left of page</div> |
135 <div class="right">Right of page</div> | 135 <div class="right">Right of page</div> |
136 <div class="middle">Middle of page</div> | 136 <div class="middle">Middle of page</div> |
OLD | NEW |