Chromium Code Reviews| 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..b989f2da07b03aa047706992a4e40bfb8d0115d6 100644 |
| --- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp |
| @@ -4292,4 +4292,57 @@ 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;}" |
| + " #forceScroll {width:1px; height:3000px; }" |
|
skobes
2017/02/13 19:02:03
You can just set height on the body, no need for t
|
| + "</style>" |
| + "<div id='forceScroll'></div>", |
| + baseURL); |
| + |
| + WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| + auto* frameView = frame->frameView(); |
| + EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars()); |
| + if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
|
skobes
2017/02/13 19:02:03
Use:
EXPECT_NE(nullptr, frameView->layoutViewpo
|
| + EXPECT_NE( |
| + nullptr, |
| + frameView->layoutView()->getScrollableArea()->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->layoutView()->getScrollableArea()->verticalScrollbar()); |
| + } else { |
| + EXPECT_NE(nullptr, frameView->verticalScrollbar()); |
| + } |
| +} |
| + |
| } // namespace blink |