| Index: third_party/WebKit/Source/web/tests/RootScrollerTest.cpp
|
| diff --git a/third_party/WebKit/Source/web/tests/RootScrollerTest.cpp b/third_party/WebKit/Source/web/tests/RootScrollerTest.cpp
|
| index d9b834039bbf12d79ddf73ad4da3dc0a46fd631c..cdfaa2c31f21059d82ab43bda0afbd21b547f1fc 100644
|
| --- a/third_party/WebKit/Source/web/tests/RootScrollerTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/RootScrollerTest.cpp
|
| @@ -2,10 +2,12 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "core/dom/ClientRect.h"
|
| #include "core/frame/BrowserControls.h"
|
| #include "core/frame/FrameHost.h"
|
| #include "core/frame/FrameView.h"
|
| #include "core/frame/RootFrameViewport.h"
|
| +#include "core/frame/VisualViewport.h"
|
| #include "core/html/HTMLFrameOwnerElement.h"
|
| #include "core/layout/LayoutBox.h"
|
| #include "core/layout/api/LayoutViewItem.h"
|
| @@ -41,6 +43,7 @@ class RootScrollerTest : public ::testing::Test {
|
| RootScrollerTest() : m_baseURL("http://www.test.com/") {
|
| registerMockedHttpURLLoad("overflow-scrolling.html");
|
| registerMockedHttpURLLoad("root-scroller.html");
|
| + registerMockedHttpURLLoad("root-scroller-rotation.html");
|
| registerMockedHttpURLLoad("root-scroller-iframe.html");
|
| registerMockedHttpURLLoad("root-scroller-child.html");
|
| }
|
| @@ -987,6 +990,61 @@ TEST_F(RootScrollerTest, UseVisualViewportScrollbarsIframe) {
|
| EXPECT_GT(containerScroller->maximumScrollOffset().height(), 0);
|
| }
|
|
|
| +TEST_F(RootScrollerTest, RotationAnchoring) {
|
| + initialize("root-scroller-rotation.html");
|
| +
|
| + ScrollableArea* containerScroller;
|
| +
|
| + {
|
| + webViewImpl()->resizeWithBrowserControls(IntSize(250, 1000), 0, true);
|
| + mainFrameView()->updateAllLifecyclePhases();
|
| +
|
| + Element* container = mainFrame()->document()->getElementById("container");
|
| + NonThrowableExceptionState nonThrow;
|
| + mainFrame()->document()->setRootScroller(container, nonThrow);
|
| + mainFrameView()->updateAllLifecyclePhases();
|
| +
|
| + containerScroller = static_cast<PaintInvalidationCapableScrollableArea*>(
|
| + toLayoutBox(container->layoutObject())->getScrollableArea());
|
| + }
|
| +
|
| + Element* target = mainFrame()->document()->getElementById("target");
|
| +
|
| + // Zoom in and scroll the viewport so that the target is fully in the
|
| + // viewport and the visual viewport is fully scrolled within the layout
|
| + // viepwort.
|
| + {
|
| + int scrollX = 250 * 4;
|
| + int scrollY = 1000 * 4;
|
| +
|
| + webViewImpl()->setPageScaleFactor(2);
|
| + webViewImpl()->handleInputEvent(
|
| + generateTouchGestureEvent(WebInputEvent::GestureScrollBegin));
|
| + webViewImpl()->handleInputEvent(generateTouchGestureEvent(
|
| + WebInputEvent::GestureScrollUpdate, -scrollX, -scrollY));
|
| + webViewImpl()->handleInputEvent(
|
| + generateTouchGestureEvent(WebInputEvent::GestureScrollEnd));
|
| +
|
| + // The visual viewport should be 1.5 screens scrolled so that the target
|
| + // occupies the bottom quadrant of the layout viewport.
|
| + ASSERT_EQ((250 * 3) / 2, containerScroller->scrollOffset().width());
|
| + ASSERT_EQ((1000 * 3) / 2, containerScroller->scrollOffset().height());
|
| +
|
| + // The visual viewport should have scrolled the last half layout viewport.
|
| + ASSERT_EQ((250) / 2, visualViewport().scrollOffset().width());
|
| + ASSERT_EQ((1000) / 2, visualViewport().scrollOffset().height());
|
| + }
|
| +
|
| + // Now do a rotation resize.
|
| + webViewImpl()->resizeWithBrowserControls(IntSize(1000, 250), 50, false);
|
| + mainFrameView()->updateAllLifecyclePhases();
|
| +
|
| + // The visual viewport should remain fully filled by the target.
|
| + ClientRect* rect = target->getBoundingClientRect();
|
| + EXPECT_EQ(rect->left(), visualViewport().scrollOffset().width());
|
| + EXPECT_EQ(rect->top(), visualViewport().scrollOffset().height());
|
| +}
|
| +
|
| } // namespace
|
|
|
| } // namespace blink
|
|
|