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 cf47dc68ac6357b3affa54b9c037503cf2bde662..135b625745a6d2b8ff597cd50b447aa155f58f94 100644 |
--- a/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp |
+++ b/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp |
@@ -1861,4 +1861,41 @@ TEST_P(ParameterizedVisualViewportTest, ResizeWithScrollAnchoring) |
RuntimeEnabledFeatures::setScrollAnchoringEnabled(wasScrollAnchoringEnabled); |
} |
+// Ensure that resize anchoring as happens when top controls hide/show affects |
+// the scrollable area that's currently set as the root scroller. |
+TEST_P(ParameterizedVisualViewportTest, ResizeAnchoringWithRootScroller) |
+{ |
+ bool wasRootScrollerEnabled = |
+ RuntimeEnabledFeatures::setRootScrollerEnabled(); |
+ RuntimeEnabledFeatures::setSetRootScrollerEnabled(true); |
+ |
+ initializeWithAndroidSettings(); |
+ webViewImpl()->resize(IntSize(800, 600)); |
+ |
+ registerMockedHttpURLLoad("root-scroller-div.html"); |
+ navigateTo(m_baseURL + "root-scroller-div.html"); |
+ |
+ FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
+ |
+ Element* scroller = frame()->document()->getElementById("rootScroller"); |
+ NonThrowableExceptionState nonThrow; |
+ frame()->document()->setRootScroller(scroller, nonThrow); |
+ |
+ webViewImpl()->setPageScaleFactor(3.f); |
+ frameView.getScrollableArea()->setScrollPosition( |
+ DoublePoint(0, 400), ProgrammaticScroll); |
+ |
+ VisualViewport& visualViewport = |
+ webViewImpl()->page()->frameHost().visualViewport(); |
+ visualViewport.setScrollPosition(DoublePoint(0, 400), ProgrammaticScroll); |
+ |
+ webViewImpl()->resize(IntSize(800, 500)); |
+ |
+ EXPECT_POINT_EQ( |
+ DoublePoint(), |
+ frameView.layoutViewportScrollableArea()->scrollPositionDouble()); |
+ |
+ RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); |
+} |
+ |
} // namespace |