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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2695493003: Ensure FrameView scrollbars are updated when changing device emulation modes (Closed)
Patch Set: sdfljsldjsf 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/frame/VisualViewport.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 4274 matching lines...) Expand 10 before | Expand all | Expand 10 after
4285 4285
4286 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); 4286 EXPECT_EQ(expectedWidth, vwElement->offsetWidth());
4287 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); 4287 EXPECT_EQ(expectedHeight, vwElement->offsetHeight());
4288 4288
4289 webView->resize(WebSize(800, 600)); 4289 webView->resize(WebSize(800, 600));
4290 frame->printEnd(); 4290 frame->printEnd();
4291 4291
4292 EXPECT_EQ(800, vwElement->offsetWidth()); 4292 EXPECT_EQ(800, vwElement->offsetWidth());
4293 } 4293 }
4294 4294
4295 TEST_P(WebViewTest, DeviceEmulationResetScrollbars) {
4296 WebViewImpl* webView = m_webViewHelper.initialize();
4297 webView->resize(WebSize(800, 600));
4298
4299 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
4300 FrameTestHelpers::loadHTMLString(webView->mainFrame(),
4301 "<!doctype html>"
4302 "<meta name='viewport'"
4303 " content='width=device-width'>"
4304 "<style>"
4305 " body {margin: 0px;}"
4306 " #forceScroll {width:1px; height:3000px; }"
skobes 2017/02/13 19:02:03 You can just set height on the body, no need for t
4307 "</style>"
4308 "<div id='forceScroll'></div>",
4309 baseURL);
4310
4311 WebLocalFrameImpl* frame = webView->mainFrameImpl();
4312 auto* frameView = frame->frameView();
4313 EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars());
4314 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
skobes 2017/02/13 19:02:03 Use: EXPECT_NE(nullptr, frameView->layoutViewpo
4315 EXPECT_NE(
4316 nullptr,
4317 frameView->layoutView()->getScrollableArea()->verticalScrollbar());
4318 } else {
4319 EXPECT_NE(nullptr, frameView->verticalScrollbar());
4320 }
4321
4322 WebDeviceEmulationParams params;
4323 params.screenPosition = WebDeviceEmulationParams::Mobile;
4324 params.deviceScaleFactor = 0;
4325 params.fitToView = false;
4326 params.offset = WebFloatPoint();
4327 params.scale = 1;
4328
4329 webView->enableDeviceEmulation(params);
4330
4331 // The visual viewport should now proivde the scrollbars instead of the view.
4332 EXPECT_TRUE(frameView->visualViewportSuppliesScrollbars());
4333 EXPECT_EQ(nullptr, frameView->verticalScrollbar());
4334
4335 webView->disableDeviceEmulation();
4336
4337 // The view should once again provide the scrollbars.
4338 EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars());
4339 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
4340 EXPECT_NE(
4341 nullptr,
4342 frameView->layoutView()->getScrollableArea()->verticalScrollbar());
4343 } else {
4344 EXPECT_NE(nullptr, frameView->verticalScrollbar());
4345 }
4346 }
4347
4295 } // namespace blink 4348 } // namespace blink
OLDNEW
« 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