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

Unified Diff: third_party/WebKit/LayoutTests/fast/scroll-behavior/main-frame-pinch-scrolls-layout-viewport.html

Issue 1366893002: Make window.scroll properties relative to the layout viewport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "worked on review comments" Created 5 years, 3 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/main-frame-pinch-scrolls-layout-viewport.html
diff --git a/third_party/WebKit/LayoutTests/fast/scroll-behavior/main-frame-pinch-scrolls-layout-viewport.html b/third_party/WebKit/LayoutTests/fast/scroll-behavior/main-frame-pinch-scrolls-layout-viewport.html
new file mode 100644
index 0000000000000000000000000000000000000000..0aa4b97febba8409550964d1b26e23a1f904c786
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/scroll-behavior/main-frame-pinch-scrolls-layout-viewport.html
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<style>
+ body {
+ width: 1000px;
+ height: 1000px;
+ /* Overflow hidden so that the size of the scrollbar is not added to
+ the innerHeight/Width properties. */
+ overflow: hidden;
+ }
+</style>
+<script src="../../resources/js-test.js"></script>
+
+<script type="text/javascript">
+ var testScrolls = [];
+ var currentTest = -1;
+
+ setPrintTestResultsLazily();
+ jsTestIsAsync = true;
+
+ description("Test that when the scrollLayoutViewport setting is on, the scroll " +
+ "from window.scrollTo is applied to the layout viewport. Note that this test is " +
+ "pertaining to crbug.com/489206, where we want all APIs to reflect the layout viewport.");
+
+ function finishTest() {
+ var testCase = testScrolls[currentTest];
+ if(window.scrollX == testCase.expectedX && window.scrollY == testCase.expectedY) {
+ testPassed("Scroll destination reached.");
+ startNextTestCase();
+ } else {
+ testFailed("Scroll destination not reached.");
+ startNextTestCase();
+ }
+ }
+
+ function startNextTestCase() {
+ currentTest++;
+ if (currentTest >= testScrolls.length) {
+ finishJSTest();
+ return;
+ }
+
+ var testCase = testScrolls[currentTest];
+ internals.settings.setInertVisualViewport(testScrolls[currentTest].scrollLayoutViewport);
+ window.scrollTo(testCase.x, testCase.y);
+ window.requestAnimationFrame(finishTest);
+ }
+
+ window.onload = function () {
+ if (!window.internals) {
+ testFailed('This test requires window.internals');
+ finishJSTest();
+ return;
+ }
+
+ internals.settings.setInertVisualViewport(false);
+ // The height/width of the layout viewport is innerHeight/Width of the window
+ // when no pinch-zoom is applied.
+ var layoutInnerHeight = window.innerHeight;
+ var layoutInnerWidth = window.innerWidth;
+ // The height/width of the visual viewport is innerHeight/Width of the window
+ // when pinch-zoom is applied.
+ internals.setPageScaleFactor(2.0);
+ var visualInnerHeight = window.innerHeight;
+ var visualInnerWidth = window.innerWidth;
+
+ // The maximum scroll offsets when the visual viewport is scrolled.
+ var maxScrollHeightScrollVisual = document.scrollingElement.scrollHeight - visualInnerHeight;
+ var maxScrollWidthScrollVisual = document.scrollingElement.scrollWidth - visualInnerWidth;
+ // The maximum scroll offsets when the layout viewport is scrolled.
+ var maxScrollHeightScrollLayout = document.scrollingElement.scrollHeight - layoutInnerHeight;
+ var maxScrollWidthScrollLayout = document.scrollingElement.scrollWidth - layoutInnerWidth;
+
+ // First scrollTo is called with the scrollLayoutViewport setting off, in which
+ // case, window.scrollY should return the position of the visual viewport. Then
+ // the setting is turned on, and this time, window.scrollY should return the
+ // position of the layoutViewport.
+ testScrolls = [
+ {x: 2000, y: 2000, expectedX: maxScrollWidthScrollVisual, expectedY:maxScrollHeightScrollVisual, scrollLayoutViewport:false},
+ {x: 2000, y: 2000, expectedX: maxScrollWidthScrollLayout, expectedY:maxScrollHeightScrollLayout, scrollLayoutViewport:true},
+ ];
+ startNextTestCase();
+ }
+</script>

Powered by Google App Engine
This is Rietveld 408576698