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

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

Issue 1356113002: Make window.scroll properties relative to the layout viewport. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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: LayoutTests/fast/scroll-behavior/main-frame-pinch-scrolls-layout-viewport.html
diff --git a/LayoutTests/fast/scroll-behavior/main-frame-pinch-scrolls-layout-viewport.html b/LayoutTests/fast/scroll-behavior/main-frame-pinch-scrolls-layout-viewport.html
new file mode 100644
index 0000000000000000000000000000000000000000..9e431e5332ecf193b5c833e5f29908e68fefc525
--- /dev/null
+++ b/LayoutTests/fast/scroll-behavior/main-frame-pinch-scrolls-layout-viewport.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<style>
+ body {
+ width: 600px;
+ height: 1000px;
+ }
+</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.setScrollLayoutViewport(testScrolls[currentTest].scrollLayoutViewport);
+ window.scrollTo(testCase.x, testCase.y);
+ window.requestAnimationFrame(finishTest);
+ }
+
+ window.onload = function () {
+ if (!window.internals) {
+ testFailed('This test requires window.internals');
bokan 2015/09/21 16:49:12 should you return after this?
ymalik (do not use) 2015/09/21 20:35:50 Absolutely!
+ }
+
+ internals.settings.setScrollLayoutViewport(false);
+ // The height of the layout viewport is innerHeight of the window when no
+ // pinch-zoom is applied.
+ var layoutInnerHeight = window.innerHeight;
+ // The height of the visual viewport is innerHeight of the window when
+ // pinch-zoom is applied.
+ internals.setPageScaleFactor(2.0);
+ var visualInnerHeight = window.innerHeight;
bokan 2015/09/21 16:49:12 Please also add a case for verifying the innerWidt
ymalik (do not use) 2015/09/21 20:35:49 Acknowledged. That's fair. I was trying to follow
bokan 2015/09/21 20:59:56 Good, consistency is usually the trump card.
+
+ // The maximum scrollTop when the visual viewport is scrolled.
+ var maxScrollHeightScrollVisual = document.scrollingElement.scrollHeight - visualInnerHeight;
+ // The maximum scrollTop when the layout viewport is scrolled.
+ var maxScrollHeightScrollLayout = document.scrollingElement.scrollHeight - layoutInnerHeight;
+
+ // 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: 0, y: 2000, expectedX: 0, expectedY:maxScrollHeightScrollVisual, scrollLayoutViewport:false},
bokan 2015/09/21 16:49:12 Please also test the horizontal axis
ymalik (do not use) 2015/09/21 20:35:49 Done.
+ {x: 0, y: 2000, expectedX: 0, expectedY:maxScrollHeightScrollLayout, scrollLayoutViewport:true},
+ ];
+ startNextTestCase();
+ }
+</script>

Powered by Google App Engine
This is Rietveld 408576698