Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../../../resources/js-test.js"></script> | |
| 3 <style> | |
| 4 body { | |
| 5 height: 2000px; | |
| 6 width: 2000px; | |
| 7 } | |
| 8 </style> | |
| 9 | |
| 10 <script> | |
| 11 window.jsTestIsAsync = true; | |
| 12 | |
| 13 var documentElement; | |
| 14 | |
| 15 description("This test verifies the dimensions of the visual viewport \ | |
| 16 returned by JS visual viewport API."); | |
|
bokan
2016/03/18 16:05:07
nit: "by JS" -> "by the JS"
ymalik
2016/03/22 16:35:05
Done.
| |
| 17 | |
| 18 function runTest() { | |
| 19 if (!window.eventSender || !window.internals) { | |
| 20 finishJSTest(); | |
| 21 return; | |
| 22 } | |
| 23 | |
| 24 documentElement = document.documentElement; | |
| 25 | |
| 26 // Turn off smooth scrolling. | |
| 27 internals.settings.setScrollAnimatorEnabled(false); | |
| 28 | |
| 29 // Scroll both viewports. | |
| 30 eventSender.mouseMoveTo(100, 100); | |
| 31 eventSender.continuousMouseScrollBy(100, 100); | |
| 32 | |
| 33 debug(" **** Initial visual viewport dimensions *****"); | |
| 34 shouldBe("documentElement.viewport.scrollTop", "0"); | |
| 35 shouldBe("documentElement.viewport.scrollLeft", "0"); | |
| 36 shouldBe("documentElement.viewport.clientWidth", "800"); | |
| 37 shouldBe("documentElement.viewport.clientHeight", "600"); | |
| 38 shouldBe("documentElement.viewport.pageScale", "1"); | |
| 39 | |
| 40 // Scale and scroll visual viewport. | |
| 41 internals.setPageScaleFactor(2); | |
| 42 internals.setVisualViewportOffset(10, 10); | |
| 43 | |
| 44 debug(" **** Viewport dimensions after scale and scroll *****"); | |
| 45 shouldBe("documentElement.viewport.scrollTop", "10"); | |
| 46 shouldBe("documentElement.viewport.scrollLeft", "10"); | |
| 47 shouldBe("documentElement.viewport.clientWidth", "400"); | |
| 48 shouldBe("documentElement.viewport.clientHeight", "300"); | |
| 49 shouldBe("documentElement.viewport.pageScale", "2"); | |
| 50 | |
| 51 document.scrollingElement.viewport.scrollTop = 20; | |
|
bokan
2016/03/18 16:05:07
scrollingElement->documentElement
ymalik
2016/03/22 16:35:05
Done.
| |
| 52 document.scrollingElement.viewport.scrollLeft = 0; | |
| 53 debug(" **** Writable viewport dimensions *****"); | |
| 54 shouldBe("documentElement.viewport.scrollTop", "20"); | |
| 55 shouldBe("documentElement.viewport.scrollLeft", "0"); | |
| 56 document.scrollingElement.viewport.scrollTop = -20; | |
| 57 shouldBe("documentElement.viewport.scrollTop", "0"); | |
| 58 | |
| 59 finishJSTest(); | |
| 60 } | |
| 61 </script> | |
| 62 | |
| 63 <body onload="runTest()"></body> | |
| OLD | NEW |