| 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 418e6480cd5f46389c1a47420f68a29dbdcb0223..68af0e71715fc25b22982881f3a5c2d0e9b4041e 100644
|
| --- a/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
|
| @@ -307,6 +307,54 @@ 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.
|
| + bool rootLayerScrolls = RuntimeEnabledFeatures::rootLayerScrollingEnabled();
|
| +
|
| + 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.
|
| + if (!rootLayerScrolls)
|
| + EXPECT_TRUE(scroller->horizontalScrollbar());
|
| + else
|
| + EXPECT_FALSE(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.
|
| + if (!rootLayerScrolls) {
|
| + EXPECT_FLOAT_EQ(100, scroller->horizontalScrollbar()->currentPos());
|
| + EXPECT_FLOAT_EQ(300, scroller->verticalScrollbar()->currentPos());
|
| + } else {
|
| + EXPECT_FLOAT_EQ(200, scroller->verticalScrollbar()->currentPos());
|
| + }
|
| +}
|
| +
|
| // Test that the VisualViewport works as expected in case of a scaled
|
| // and scrolled viewport - scroll down.
|
| TEST_P(VisualViewportTest, TestResizeAfterVerticalScroll) {
|
|
|