Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/WebKit/LayoutTests/fast/scroll-behavior/scroll-into-view-scrolls-layout-viewport.html

Issue 1424313003: element.scrollIntoView only scrolls the layout viewport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/scroll-behavior/scroll-into-view-scrolls-layout-viewport.html
diff --git a/third_party/WebKit/LayoutTests/fast/scroll-behavior/scroll-into-view-scrolls-layout-viewport.html b/third_party/WebKit/LayoutTests/fast/scroll-behavior/scroll-into-view-scrolls-layout-viewport.html
new file mode 100644
index 0000000000000000000000000000000000000000..92fd6b5b2efdb49c363fb1cc91294f1223d840d5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/scroll-behavior/scroll-into-view-scrolls-layout-viewport.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<style>
+ #box {
+ background-color: black;
+ top: 400px;
+ left: 100px;
+ height: 40px;
+ width: 40px;
+ position: absolute;
+ }
+</style>
+<script src="../../resources/js-test.js"></script>
+<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.
+ if (window.testRunner && window.internals) {
+ window.jsTestIsAsync = true;
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ setPrintTestResultsLazily();
+ }
+
+ description("Test that element.scrollIntoView() only scrolls the layout\
+ viewport when the intertVisualViewport is set.");
+
+ function runTest() {
+ if (!window.testRunner || !window.internals) {
+ testFailed("This test requires test runner and internals");
+ finishJSTest();
+ return;
+ }
+ internals.setPageScaleFactor(2.0);
+ var target = document.getElementById("box");
+
+ 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.
+ internals.setVisualViewportOffset(0, 0);
+ target.scrollIntoView();
+ shouldBe('internals.visualViewportScrollX()', '0');
+ shouldBe('internals.visualViewportScrollY()', '300');
+ internals.setVisualViewportOffset(0, 0);
+ target.scrollIntoViewIfNeeded();
+ shouldBe('internals.visualViewportScrollX()', '0');
+ shouldBe('internals.visualViewportScrollY()', '270');
+
+ 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.
+ internals.setVisualViewportOffset(0, 0);
+ target.scrollIntoView();
+ shouldBe('internals.visualViewportScrollX()', '0');
+ shouldBe('internals.visualViewportScrollY()', '0');
+ internals.setVisualViewportOffset(0, 0);
+ target.scrollIntoViewIfNeeded();
+ shouldBe('internals.visualViewportScrollX()', '0');
+ shouldBe('internals.visualViewportScrollY()', '0');
+
+ finishJSTest();
+ }
+
+ onload = runTest;
+</script>
+
+<div id="box"></div>

Powered by Google App Engine
This is Rietveld 408576698