| Index: third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| diff --git a/third_party/WebKit/Source/web/tests/WebViewTest.cpp b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| index 3963284e20c708bdeb21c5834475260f8abf3af8..87d0d515b38f97ec0d3333f7def605d26eac153b 100644
|
| --- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
|
| @@ -4292,4 +4292,53 @@ TEST_P(WebViewTest, ResizeForPrintingViewportUnits) {
|
| EXPECT_EQ(800, vwElement->offsetWidth());
|
| }
|
|
|
| +TEST_P(WebViewTest, DeviceEmulationResetScrollbars) {
|
| + WebViewImpl* webView = m_webViewHelper.initialize();
|
| + webView->resize(WebSize(800, 600));
|
| +
|
| + WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
|
| + FrameTestHelpers::loadHTMLString(webView->mainFrame(),
|
| + "<!doctype html>"
|
| + "<meta name='viewport'"
|
| + " content='width=device-width'>"
|
| + "<style>"
|
| + " body {margin: 0px; height:3000px;}"
|
| + "</style>",
|
| + baseURL);
|
| +
|
| + WebLocalFrameImpl* frame = webView->mainFrameImpl();
|
| + auto* frameView = frame->frameView();
|
| + EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars());
|
| + if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
|
| + EXPECT_NE(nullptr,
|
| + frameView->layoutViewportScrollableArea()->verticalScrollbar());
|
| + } else {
|
| + EXPECT_NE(nullptr, frameView->verticalScrollbar());
|
| + }
|
| +
|
| + WebDeviceEmulationParams params;
|
| + params.screenPosition = WebDeviceEmulationParams::Mobile;
|
| + params.deviceScaleFactor = 0;
|
| + params.fitToView = false;
|
| + params.offset = WebFloatPoint();
|
| + params.scale = 1;
|
| +
|
| + webView->enableDeviceEmulation(params);
|
| +
|
| + // The visual viewport should now proivde the scrollbars instead of the view.
|
| + EXPECT_TRUE(frameView->visualViewportSuppliesScrollbars());
|
| + EXPECT_EQ(nullptr, frameView->verticalScrollbar());
|
| +
|
| + webView->disableDeviceEmulation();
|
| +
|
| + // The view should once again provide the scrollbars.
|
| + EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars());
|
| + if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
|
| + EXPECT_NE(nullptr,
|
| + frameView->layoutViewportScrollableArea()->verticalScrollbar());
|
| + } else {
|
| + EXPECT_NE(nullptr, frameView->verticalScrollbar());
|
| + }
|
| +}
|
| +
|
| } // namespace blink
|
|
|