Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <style> | |
| 3 #box { | |
| 4 background-color: black; | |
| 5 top: 400px; | |
| 6 left: 100px; | |
| 7 height: 40px; | |
| 8 width: 40px; | |
| 9 position: absolute; | |
| 10 } | |
| 11 </style> | |
| 12 <script src="../../resources/js-test.js"></script> | |
| 13 <script language="JavaScript" type="text/javascript"> | |
|
bokan
2015/10/30 16:08:55
nit: I think it's idiomatic now to leave the langu
ymalik
2015/11/01 00:02:24
Done.
| |
| 14 if (window.testRunner && window.internals) { | |
| 15 window.jsTestIsAsync = true; | |
| 16 testRunner.dumpAsText(); | |
| 17 testRunner.waitUntilDone(); | |
| 18 setPrintTestResultsLazily(); | |
| 19 } | |
| 20 | |
| 21 description("Test that element.scrollIntoView() only scrolls the layout\ | |
| 22 viewport when the intertVisualViewport is set."); | |
| 23 | |
| 24 function runTest() { | |
| 25 if (!window.testRunner || !window.internals) { | |
| 26 testFailed("This test requires test runner and internals"); | |
| 27 finishJSTest(); | |
| 28 return; | |
| 29 } | |
| 30 internals.setPageScaleFactor(2.0); | |
| 31 var target = document.getElementById("box"); | |
| 32 | |
| 33 internals.settings.setInertVisualViewport(false); | |
|
bokan
2015/10/30 16:08:55
I don't think there's a need to test the "off" cas
ymalik
2015/11/01 00:02:24
Acknowledged.
| |
| 34 internals.setVisualViewportOffset(0, 0); | |
| 35 target.scrollIntoView(); | |
| 36 shouldBe('internals.visualViewportScrollX()', '0'); | |
| 37 shouldBe('internals.visualViewportScrollY()', '300'); | |
| 38 internals.setVisualViewportOffset(0, 0); | |
| 39 target.scrollIntoViewIfNeeded(); | |
| 40 shouldBe('internals.visualViewportScrollX()', '0'); | |
| 41 shouldBe('internals.visualViewportScrollY()', '270'); | |
| 42 | |
| 43 internals.settings.setInertVisualViewport(true); | |
|
bokan
2015/10/30 16:08:55
I would add some layout viewport scrolling and put
ymalik
2015/11/01 00:02:24
Definitely a better test. Thanks.
| |
| 44 internals.setVisualViewportOffset(0, 0); | |
| 45 target.scrollIntoView(); | |
| 46 shouldBe('internals.visualViewportScrollX()', '0'); | |
| 47 shouldBe('internals.visualViewportScrollY()', '0'); | |
| 48 internals.setVisualViewportOffset(0, 0); | |
| 49 target.scrollIntoViewIfNeeded(); | |
| 50 shouldBe('internals.visualViewportScrollX()', '0'); | |
| 51 shouldBe('internals.visualViewportScrollY()', '0'); | |
| 52 | |
| 53 finishJSTest(); | |
| 54 } | |
| 55 | |
| 56 onload = runTest; | |
| 57 </script> | |
| 58 | |
| 59 <div id="box"></div> | |
| OLD | NEW |