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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/Window/window-scaled-viewport-properties.html

Issue 1415513002: Remove plumbing for inert-visual-viewport flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Worked on review comments 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/dom/Window/window-scaled-viewport-properties.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Window/window-scaled-viewport-properties.html b/third_party/WebKit/LayoutTests/fast/dom/Window/window-scaled-viewport-properties.html
index 790c0bfbb22286ea447e149c71c4098e7f569773..ae17afdc8b08d40462d2463a240507e0619f9c1b 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/Window/window-scaled-viewport-properties.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/Window/window-scaled-viewport-properties.html
@@ -4,6 +4,9 @@
body {
padding: 0px;
margin: 0px;
+ /* Overflow hidden so that the size of the scrollbar is not added to
+ the innerHeight/Width properties. */
+ overflow: hidden;
}
.spacer {
@@ -18,45 +21,78 @@
</style>
<script language="JavaScript" type="text/javascript">
if (window.testRunner && window.internals) {
+ // Note that the layout viewport is based on the minimum page scale.
+ // Thus, the minimum scale of 0.5 causes the layout viewport to become
+ // twice of what we would normally expect.
window.internals.setPageScaleFactorLimits(0.5, 4.0);
window.jsTestIsAsync = true;
testRunner.dumpAsText();
testRunner.waitUntilDone();
+ setPrintTestResultsLazily();
}
description("This test makes sure the window properties related to the\
viewport remain correct under pinch-to-zoom.");
- debug('===Unscaled===');
- debug('');
- shouldBe('window.innerWidth', '800');
- shouldBe('window.innerHeight', '600');
+
+ function testUnscaled () {
+ debug('===Unscaled===');
bokan 2015/10/21 13:32:14 This is misleading since it's actually at 0.5 scal
ymalik 2015/10/21 15:14:08 Done.
+ debug('');
+ shouldBe('window.innerWidth', '1600');
+ shouldBe('window.innerHeight', '1200');
+ shouldBe('internals.visualViewportWidth()', '1600');
+ shouldBe('internals.visualViewportHeight()', '1200');
+ }
+
+ function jsScrollTo(x, y) {
+ window.scrollTo(x, y);
+ }
+
+ function jsScrollBy(x, y) {
+ window.scrollBy(x, y);
+ }
+
+ function testScrolls(jsScroll) {
+ // Test that the layout and visual viewport viewport scroll.
+ jsScroll(100, 200);
+ shouldBe('window.scrollX', '100');
+ shouldBe('window.scrollY', '200');
+ shouldBe('internals.visualViewportScrollX()', '100');
+ shouldBe('internals.visualViewportScrollY()', '200');
+
+ // Test that the scroll doesn't bubble to the visual viewport.
+ jsScroll(1500, 1100);
+ shouldBe('window.scrollX', '400');
+ shouldBe('window.scrollY', '300');
+ shouldBe('internals.visualViewportScrollX()', '400');
+ shouldBe('internals.visualViewportScrollY()', '300');
+
+ // Reset.
+ window.scrollTo(0, 0);
+ shouldBe('window.scrollX', '0');
+ shouldBe('window.scrollY', '0');
+ }
function testPinchedIn() {
debug('');
debug('===Pinch Zoom in to 2X===');
debug('');
window.internals.setPageScaleFactor(2.0);
- shouldBe('window.innerWidth', '400');
- shouldBe('window.innerHeight', '300');
+ // Test that the innerWidth, innerHeight, scrollX, scrollY are relative
+ // to the layout viewport after page scale.
+ shouldBe('window.innerWidth', '1600');
+ shouldBe('window.innerHeight', '1200');
shouldBe('window.scrollX', '0');
shouldBe('window.scrollY', '0');
- window.scrollBy(10, 20);
- shouldBe('window.scrollX', '10');
- shouldBe('window.scrollY', '20');
- window.scrollBy(1590, 1180);
- shouldBe('window.scrollX', '1600');
- shouldBe('window.scrollY', '1200');
- window.scrollBy(-1600, -1200);
- shouldBe('window.scrollX', '0');
- shouldBe('window.scrollY', '0');
- window.scrollTo(1600, 1200);
- shouldBe('window.scrollX', '1600');
- shouldBe('window.scrollY', '1200');
- window.scrollTo(0, 0);
- shouldBe('window.scrollX', '0');
- shouldBe('window.scrollY', '0');
+ // Test that the visual viewport size changes after page scale.
+ shouldBe('internals.visualViewportWidth()', '400');
+ shouldBe('internals.visualViewportHeight()', '300');
+
+ debug('===ScrollBy===');
+ testScrolls(jsScrollBy);
+ debug('===ScrollTo===');
+ testScrolls(jsScrollTo);
}
function testMaximallyPinchedOut() {
@@ -68,22 +104,13 @@
shouldBe('window.innerHeight', '1200');
shouldBe('window.scrollX', '0');
shouldBe('window.scrollY', '0');
+ shouldBe('internals.visualViewportWidth()', '1600');
+ shouldBe('internals.visualViewportHeight()', '1200');
- window.scrollBy(10, 20);
- shouldBe('window.scrollX', '10');
- shouldBe('window.scrollY', '20');
- window.scrollBy(390, 280);
- shouldBe('window.scrollX', '400');
- shouldBe('window.scrollY', '300');
- window.scrollBy(-400, -300);
- shouldBe('window.scrollX', '0');
- shouldBe('window.scrollY', '0');
- window.scrollTo(400, 300);
- shouldBe('window.scrollX', '400');
- shouldBe('window.scrollY', '300');
- window.scrollTo(0, 0);
- shouldBe('window.scrollX', '0');
- shouldBe('window.scrollY', '0');
+ debug('===ScrollBy===');
+ testScrolls(jsScrollBy);
+ debug('===ScrollTo===');
+ testScrolls(jsScrollTo);
}
function testOnScroll() {
@@ -91,15 +118,15 @@
debug('===Test OnScroll===');
debug('');
window.internals.setPageScaleFactor(1.0);
- shouldBe('window.innerWidth', '800');
- shouldBe('window.innerHeight', '600');
+ shouldBe('window.innerWidth', '1600');
+ shouldBe('window.innerHeight', '1200');
shouldBe('window.scrollX', '0');
shouldBe('window.scrollY', '0');
- // First scroll scrolls only the outer viewport.
- // Second scrolls the outer and the inner.
- // Third scrolls only the inner.
- var scrolls = [100, 400, 100];
+ // First scroll scrolls the layout viewport fully. This should trigger
+ // a call to onscroll. The second scroll attempts to scroll a fully
+ // scrolled page and should not trigger onscroll.
+ var scrolls = [400, 100];
var numScrollsReceived = 0;
var numRAFCalls = 0;
@@ -113,9 +140,8 @@
var scrollAmount = scrolls[numScrollsReceived];
window.scrollBy(scrollAmount, 0);
} else if (numScrollsReceived == scrolls.length) {
- // Make sure scrollTo that moves only the inner viewport also
- // triggers a scroll event.
- window.scrollTo(1200, 0);
+ testFailed("Received visual viewport scroll event");
bokan 2015/10/21 13:32:14 The failure message is wrong (and success message
ymalik 2015/10/21 15:14:08 Done.
+ finishJSTest();
} else {
debug('');
finishJSTest();
@@ -127,8 +153,12 @@
var failureSentinel = function() {
if (numRAFCalls == 0) {
window.scrollBy(scrolls[0], 0);
bokan 2015/10/21 13:32:14 On second thought, this has nothing to do with pag
ymalik 2015/10/21 15:14:08 Removed test.
- }else if (numRAFCalls > numScrollsReceived) {
- testFailed("Failed to receive scroll event #" + (numScrollsReceived+1));
+ } else if (numRAFCalls == scrolls.length && numScrollsReceived < numRAFCalls) {
+ testPassed("Did not receive visual viewport scroll event");
+ debug('');
+ finishJSTest();
+ } else if (numRAFCalls > numScrollsReceived) {
+ testFailed("Did not receive scroll event #" + (numScrollsReceived+1));
finishJSTest();
}
++numRAFCalls;
@@ -139,12 +169,15 @@
}
function forceLayout() {
- window.scrollTo(0, 0);
+ window.scrollX;
}
function runTests() {
if (window.testRunner && window.internals) {
+ // TODO(ymalik): The call to setPageScaleFactorLimits should force
+ // layout. Fix that instead of forcing layout here.
forceLayout();
+ testUnscaled();
testPinchedIn();
testMaximallyPinchedOut();
testOnScroll();

Powered by Google App Engine
This is Rietveld 408576698