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

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: Rename settings flag and improved tests 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
« no previous file with comments | « no previous file | LayoutTests/fast/scroll-behavior/main-frame-pinch-scrolls-layout-viewport-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0aa4b97febba8409550964d1b26e23a1f904c786
--- /dev/null
+++ b/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;
bokan 2015/09/21 20:59:57 I typically use CSS to give the scrollbar no width
ymalik 2015/09/24 00:17:42 Acknowledged.
+ }
+</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>
« no previous file with comments | « no previous file | LayoutTests/fast/scroll-behavior/main-frame-pinch-scrolls-layout-viewport-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698