OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 body { |
| 4 width: 1000px; |
| 5 height: 1000px; |
| 6 /* Overflow hidden so that the size of the scrollbar is not added to |
| 7 the innerHeight/Width properties. */ |
| 8 overflow: hidden; |
| 9 } |
| 10 </style> |
| 11 <script src="../../resources/js-test.js"></script> |
| 12 |
| 13 <script type="text/javascript"> |
| 14 var testScrolls = []; |
| 15 var currentTest = -1; |
| 16 |
| 17 setPrintTestResultsLazily(); |
| 18 jsTestIsAsync = true; |
| 19 |
| 20 description("Test that when the scrollLayoutViewport setting is on, the scroll
" + |
| 21 "from window.scrollTo is applied to the layout viewport. Note that this test
is " + |
| 22 "pertaining to crbug.com/489206, where we want all APIs to reflect the layou
t viewport."); |
| 23 |
| 24 function finishTest() { |
| 25 var testCase = testScrolls[currentTest]; |
| 26 if(window.scrollX == testCase.expectedX && window.scrollY == testCase.expect
edY) { |
| 27 testPassed("Scroll destination reached."); |
| 28 startNextTestCase(); |
| 29 } else { |
| 30 testFailed("Scroll destination not reached."); |
| 31 startNextTestCase(); |
| 32 } |
| 33 } |
| 34 |
| 35 function startNextTestCase() { |
| 36 currentTest++; |
| 37 if (currentTest >= testScrolls.length) { |
| 38 finishJSTest(); |
| 39 return; |
| 40 } |
| 41 |
| 42 var testCase = testScrolls[currentTest]; |
| 43 internals.settings.setInertVisualViewport(testScrolls[currentTest].scrollLay
outViewport); |
| 44 window.scrollTo(testCase.x, testCase.y); |
| 45 window.requestAnimationFrame(finishTest); |
| 46 } |
| 47 |
| 48 window.onload = function () { |
| 49 if (!window.internals) { |
| 50 testFailed('This test requires window.internals'); |
| 51 finishJSTest(); |
| 52 return; |
| 53 } |
| 54 |
| 55 internals.settings.setInertVisualViewport(false); |
| 56 // The height/width of the layout viewport is innerHeight/Width of the windo
w |
| 57 // when no pinch-zoom is applied. |
| 58 var layoutInnerHeight = window.innerHeight; |
| 59 var layoutInnerWidth = window.innerWidth; |
| 60 // The height/width of the visual viewport is innerHeight/Width of the windo
w |
| 61 // when pinch-zoom is applied. |
| 62 internals.setPageScaleFactor(2.0); |
| 63 var visualInnerHeight = window.innerHeight; |
| 64 var visualInnerWidth = window.innerWidth; |
| 65 |
| 66 // The maximum scroll offsets when the visual viewport is scrolled. |
| 67 var maxScrollHeightScrollVisual = document.scrollingElement.scrollHeight - v
isualInnerHeight; |
| 68 var maxScrollWidthScrollVisual = document.scrollingElement.scrollWidth - vis
ualInnerWidth; |
| 69 // The maximum scroll offsets when the layout viewport is scrolled. |
| 70 var maxScrollHeightScrollLayout = document.scrollingElement.scrollHeight - l
ayoutInnerHeight; |
| 71 var maxScrollWidthScrollLayout = document.scrollingElement.scrollWidth - lay
outInnerWidth; |
| 72 |
| 73 // First scrollTo is called with the scrollLayoutViewport setting off, in wh
ich |
| 74 // case, window.scrollY should return the position of the visual viewport. T
hen |
| 75 // the setting is turned on, and this time, window.scrollY should return the |
| 76 // position of the layoutViewport. |
| 77 testScrolls = [ |
| 78 {x: 2000, y: 2000, expectedX: maxScrollWidthScrollVisual, expectedY:maxScr
ollHeightScrollVisual, scrollLayoutViewport:false}, |
| 79 {x: 2000, y: 2000, expectedX: maxScrollWidthScrollLayout, expectedY:maxScr
ollHeightScrollLayout, scrollLayoutViewport:true}, |
| 80 ]; |
| 81 startNextTestCase(); |
| 82 } |
| 83 </script> |
OLD | NEW |