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

Unified Diff: third_party/WebKit/Source/web/tests/VisualViewportTest.cpp

Issue 2454913003: MainFrame scrollbars should work with RFV instead of FV (Closed)
Patch Set: Fix VisualViewportTest Created 4 years, 1 month 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/Source/web/tests/VisualViewportTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp b/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
index eae62086b723a87d8bac51caeb859d0c8cacd584..4bb809848262d190b90b8995543f32e3101a5570 100644
--- a/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
+++ b/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
@@ -305,6 +305,48 @@ TEST_P(VisualViewportTest, TestResizeAtFullyScrolledPreservesViewportLocation) {
frameView.getScrollableArea()->visibleContentRect().location());
}
+// Test the main frame scrollbars take visual viewport into account.
+TEST_P(VisualViewportTest, VerifyScrollbarBehavior) {
+ // TODO(ymalik): With root layer scrolling enabled, the scroller returned
+ // by FrameView is PaintLayerScrollableArea. PLSA doesn't know about the
+ // visual viewport and thus, scrollbars aren't added when we zoom in.
+ if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
bokan 2016/11/03 19:59:59 Run the test but change the expectations below bas
ymalik 2016/11/04 18:54:18 Good tip. Done.
+ return;
+
+ initializeWithDesktopSettings();
+
+ registerMockedHttpURLLoad("200-by-800-viewport.html");
+ navigateTo(m_baseURL + "200-by-800-viewport.html");
+
+ webViewImpl()->resize(IntSize(300, 200));
+
+ ScrollableArea* scroller = frame()->view()->getScrollableArea();
+
+ // Initially, there is no horizontal scrollbar since the content fits.
+ EXPECT_FALSE(scroller->horizontalScrollbar());
+ EXPECT_TRUE(scroller->verticalScrollbar());
+
+ // Scroll layout viewport.
+ webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 200));
+ EXPECT_SIZE_EQ(ScrollOffset(0, 200), scroller->scrollOffset());
+
+ webViewImpl()->setPageScaleFactor(2.0);
+
+ // Pinch-zooming should add horizontal scrollbar.
+ EXPECT_TRUE(scroller->horizontalScrollbar());
+ EXPECT_TRUE(scroller->verticalScrollbar());
+
+ // Scroll visual viewport.
+ VisualViewport& visualViewport =
+ frame()->page()->frameHost().visualViewport();
+ visualViewport.setLocation(FloatPoint(100, 100));
+ EXPECT_FLOAT_SIZE_EQ(FloatSize(100, 100), visualViewport.scrollOffset());
+
+ // Scrollbar offset should take visual viewport into account.
+ EXPECT_FLOAT_EQ(100, scroller->horizontalScrollbar()->currentPos());
+ EXPECT_FLOAT_EQ(300, scroller->verticalScrollbar()->currentPos());
+}
+
// Test that the VisualViewport works as expected in case of a scaled
// and scrolled viewport - scroll down.
TEST_P(VisualViewportTest, TestResizeAfterVerticalScroll) {

Powered by Google App Engine
This is Rietveld 408576698