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

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

Issue 2454913003: MainFrame scrollbars should work with RFV instead of FV (Closed)
Patch Set: add test + rebase Created 4 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/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 f8ce086869b075e455506b9853c7ba6e9d419296..72c5cf423fa60ff1244cfcf1c0f334da3136bc5d 100644
--- a/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
+++ b/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
@@ -275,6 +275,42 @@ TEST_P(ParameterizedVisualViewportTest,
frameView.getScrollableArea()->visibleContentRect().location());
}
+// Test the main frame scrollbars take visual viewport into account.
+TEST_F(VisualViewportTest, VerifyScrollbarBehavior) {
+ initializeWithDesktopSettings();
+
+ registerMockedHttpURLLoad("200-by-800-viewport.html");
+ navigateTo(m_baseURL + "200-by-800-viewport.html");
+
+ webViewImpl()->resize(IntSize(300, 200));
+
+ // Initially, there is no horizontal scrollbar since the content fits.
+ EXPECT_FALSE(frame()->view()->horizontalScrollbar());
+ EXPECT_TRUE(frame()->view()->verticalScrollbar());
+
+ // Scroll layout viewport.
+ webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 200));
+ EXPECT_SIZE_EQ(
+ ScrollOffset(0, 200),
+ frame()->view()->layoutViewportScrollableArea()->scrollOffset());
+
+ webViewImpl()->setPageScaleFactor(2.0);
+
+ // Pinch-zooming should add horizontal scrollbar.
+ EXPECT_TRUE(frame()->view()->horizontalScrollbar());
+ EXPECT_TRUE(frame()->view()->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, frame()->view()->horizontalScrollbar()->currentPos());
+ EXPECT_FLOAT_EQ(300, frame()->view()->verticalScrollbar()->currentPos());
+}
+
// Test that the VisualViewport works as expected in case of a scaled
// and scrolled viewport - scroll down.
TEST_P(ParameterizedVisualViewportTest, TestResizeAfterVerticalScroll) {

Powered by Google App Engine
This is Rietveld 408576698