| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <style> | 2 <style> |
| 3 body { | 3 body { |
| 4 height: 2000px; | 4 height: 2000px; |
| 5 width: 2000px; | 5 width: 2000px; |
| 6 } | 6 } |
| 7 ::-webkit-scrollbar { | 7 ::-webkit-scrollbar { |
| 8 width: 0px; | 8 width: 0px; |
| 9 height: 0px; | 9 height: 0px; |
| 10 } | 10 } |
| 11 </style> | 11 </style> |
| 12 <script src="../../../resources/testharness.js"></script> | 12 <script src="../../../resources/testharness.js"></script> |
| 13 <script src="../../../resources/testharnessreport.js"></script> | 13 <script src="../../../resources/testharnessreport.js"></script> |
| 14 <script> | 14 <script> |
| 15 var browserZoomFactor = 1.25; | 15 var browserZoomFactor = 1.25; |
| 16 | 16 |
| 17 async_test(function(t) { | 17 async_test(function(t) { |
| 18 window.onload = t.step_func(function() { | 18 window.onload = t.step_func(function() { |
| 19 window.scrollTo(100, 100); | 19 window.scrollTo(100, 100); |
| 20 | 20 |
| 21 // TODO(ymalik): Remove hook to internals to pinch-zoom here and browser | 21 // TODO(ymalik): Remove hook to internals to pinch-zoom here and browser |
| 22 // zoom below. This will be required to upstream to w3c repo. | 22 // zoom below. This will be required to upstream to w3c repo. |
| 23 internals.setPageScaleFactor(2); | 23 internals.setPageScaleFactor(2); |
| 24 | 24 |
| 25 // Offset visual viewport by 10px. | 25 // Offset visual viewport by 10px. |
| 26 document.visualViewport.scrollTop = 10; | 26 window.visualViewport.scrollTop = 10; |
| 27 document.visualViewport.scrollLeft = 10; | 27 window.visualViewport.scrollLeft = 10; |
| 28 | 28 |
| 29 assert_equals(document.visualViewport.scrollTop, 10); | 29 assert_equals(window.visualViewport.scrollTop, 10); |
| 30 assert_equals(document.visualViewport.scrollLeft, 10); | 30 assert_equals(window.visualViewport.scrollLeft, 10); |
| 31 assert_equals(document.visualViewport.clientWidth, 400); | 31 assert_equals(window.visualViewport.clientWidth, 400); |
| 32 assert_equals(document.visualViewport.clientHeight, 300); | 32 assert_equals(window.visualViewport.clientHeight, 300); |
| 33 assert_equals(document.visualViewport.pageScale, 2); | 33 assert_equals(window.visualViewport.pageScale, 2); |
| 34 | 34 |
| 35 // Apply browser zoom. | 35 // Apply browser zoom. |
| 36 window.internals.setZoomFactor(browserZoomFactor); | 36 window.internals.setZoomFactor(browserZoomFactor); |
| 37 | 37 |
| 38 // Visual viewport dimensions should be scaled by the browser zoom factor. | 38 // Visual viewport dimensions should be scaled by the browser zoom factor. |
| 39 assert_equals(document.visualViewport.scrollTop, 10 / browserZoomFactor); | 39 assert_equals(window.visualViewport.scrollTop, 10 / browserZoomFactor); |
| 40 assert_equals(document.visualViewport.scrollLeft, 10 / browserZoomFactor); | 40 assert_equals(window.visualViewport.scrollLeft, 10 / browserZoomFactor); |
| 41 assert_equals(document.visualViewport.clientWidth, 400 / browserZoomFactor
); | 41 assert_equals(window.visualViewport.clientWidth, 400 / browserZoomFactor); |
| 42 assert_equals(document.visualViewport.clientHeight, 300 / browserZoomFacto
r); | 42 assert_equals(window.visualViewport.clientHeight, 300 / browserZoomFactor)
; |
| 43 assert_equals(document.visualViewport.pageScale, 2); | 43 assert_equals(window.visualViewport.pageScale, 2); |
| 44 | 44 |
| 45 // Verify setting the visual viewport offset under browser zoom. | 45 // Verify setting the visual viewport offset under browser zoom. |
| 46 document.visualViewport.scrollTop = 12.5; | 46 window.visualViewport.scrollTop = 12.5; |
| 47 document.visualViewport.scrollLeft = 12.5; | 47 window.visualViewport.scrollLeft = 12.5; |
| 48 assert_equals(document.visualViewport.scrollTop, 12.5); | 48 assert_equals(window.visualViewport.scrollTop, 12.5); |
| 49 assert_equals(document.visualViewport.scrollLeft, 12.5); | 49 assert_equals(window.visualViewport.scrollLeft, 12.5); |
| 50 assert_equals(document.visualViewport.clientWidth, 400 / browserZoomFactor
); | 50 assert_equals(window.visualViewport.clientWidth, 400 / browserZoomFactor); |
| 51 assert_equals(document.visualViewport.clientHeight, 300 / browserZoomFacto
r); | 51 assert_equals(window.visualViewport.clientHeight, 300 / browserZoomFactor)
; |
| 52 assert_equals(document.visualViewport.pageScale, 2); | 52 assert_equals(window.visualViewport.pageScale, 2); |
| 53 t.done(); | 53 t.done(); |
| 54 }); | 54 }); |
| 55 }, 'Verify viewport dimensions under bowser zoom.'); | 55 }, 'Verify viewport dimensions under bowser zoom.'); |
| 56 </script> | 56 </script> |
| OLD | NEW |