Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2695493003: Ensure FrameView scrollbars are updated when changing device emulation modes (Closed)
Patch Set: address comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/frame/VisualViewport.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/core/frame/VisualViewport.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698