OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 body { |
| 4 height: 800px; |
| 5 width: 800px; |
| 6 } |
| 7 #box { |
| 8 background-color: black; |
| 9 top: 700px; |
| 10 left: 100px; |
| 11 height: 40px; |
| 12 width: 40px; |
| 13 position: absolute; |
| 14 } |
| 15 </style> |
| 16 <script src="../../resources/js-test.js"></script> |
| 17 <script> |
| 18 if (window.testRunner && window.internals) { |
| 19 window.jsTestIsAsync = true; |
| 20 testRunner.dumpAsText(); |
| 21 testRunner.waitUntilDone(); |
| 22 setPrintTestResultsLazily(); |
| 23 } |
| 24 |
| 25 description("Test that element.scrollIntoView() only scrolls the layout\ |
| 26 viewport when the intertVisualViewport is set."); |
| 27 |
| 28 function runTest() { |
| 29 if (!window.testRunner || !window.internals) { |
| 30 testFailed("This test requires test runner and internals"); |
| 31 finishJSTest(); |
| 32 return; |
| 33 } |
| 34 internals.setPageScaleFactor(2.0); |
| 35 var target = document.getElementById("box"); |
| 36 |
| 37 internals.settings.setInertVisualViewport(true); |
| 38 window.scrollTo(0, 0); |
| 39 internals.setVisualViewportOffset(0, 0); |
| 40 target.scrollIntoView(); |
| 41 shouldBe('internals.visualViewportScrollX()', 'window.scrollX'); |
| 42 shouldBe('internals.visualViewportScrollY()', 'window.scrollY'); |
| 43 shouldBe('window.scrollX', '0'); |
| 44 shouldBeGreaterThan('window.scrollY', '0'); |
| 45 window.scrollTo(0, 0); |
| 46 internals.setVisualViewportOffset(0, 0); |
| 47 target.scrollIntoViewIfNeeded(); |
| 48 shouldBe('internals.visualViewportScrollX()', 'window.scrollX'); |
| 49 shouldBe('internals.visualViewportScrollY()', 'window.scrollY'); |
| 50 shouldBe('window.scrollX', '0'); |
| 51 shouldBeGreaterThan('window.scrollY', '0'); |
| 52 |
| 53 finishJSTest(); |
| 54 } |
| 55 |
| 56 onload = runTest; |
| 57 </script> |
| 58 |
| 59 <div id="box"></div> |
OLD | NEW |