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

Side by Side Diff: headless/lib/headless_browser_context_browsertest.cc

Issue 2374063002: Headless: expose WebPreferences to embedder, add --hide-scrollbars. (Closed)
Patch Set: Address comments, add test. Created 4 years, 2 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h"
11 #include "content/public/test/browser_test.h" 13 #include "content/public/test/browser_test.h"
14 #include "headless/lib/browser/headless_web_contents_impl.h"
12 #include "headless/public/domains/runtime.h" 15 #include "headless/public/domains/runtime.h"
13 #include "headless/public/headless_browser.h" 16 #include "headless/public/headless_browser.h"
14 #include "headless/public/headless_browser_context.h" 17 #include "headless/public/headless_browser_context.h"
15 #include "headless/public/headless_devtools_client.h" 18 #include "headless/public/headless_devtools_client.h"
16 #include "headless/public/headless_devtools_target.h" 19 #include "headless/public/headless_devtools_target.h"
17 #include "headless/public/headless_web_contents.h" 20 #include "headless/public/headless_web_contents.h"
18 #include "headless/test/headless_browser_test.h" 21 #include "headless/test/headless_browser_test.h"
19 #include "headless/test/test_protocol_handler.h" 22 #include "headless/test/test_protocol_handler.h"
20 #include "net/base/io_buffer.h" 23 #include "net/base/io_buffer.h"
21 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 .SetInitialURL(embedded_test_server()->GetURL("/hello.html")) 263 .SetInitialURL(embedded_test_server()->GetURL("/hello.html"))
261 .Build(); 264 .Build();
262 265
263 EXPECT_TRUE(WaitForLoad(web_contents)); 266 EXPECT_TRUE(WaitForLoad(web_contents));
264 267
265 // Similar to test above, but now we are in incognito mode, 268 // Similar to test above, but now we are in incognito mode,
266 // so nothing should be written to this directory. 269 // so nothing should be written to this directory.
267 EXPECT_TRUE(base::IsDirectoryEmpty(user_data_dir.GetPath())); 270 EXPECT_TRUE(base::IsDirectoryEmpty(user_data_dir.GetPath()));
268 } 271 }
269 272
273 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, ContextWebPreferences) {
274 // By default, hide_scrollbars should be false.
275 EXPECT_FALSE(WebPreferences().hide_scrollbars);
276
277 // Set hide_scrollbars preference to true for a new BrowserContext.
278 HeadlessBrowserContext* browser_context =
279 browser()
280 ->CreateBrowserContextBuilder()
281 .SetOverrideWebPreferencesCallback(
282 base::Bind([](headless::WebPreferences* preferences) {
283 preferences->hide_scrollbars = true;
284 }))
285 .Build();
286 HeadlessWebContents* web_contents =
287 browser_context->CreateWebContentsBuilder()
288 .SetInitialURL(GURL("about:blank"))
289 .Build();
290
291 // Verify that the preference takes effect.
292 HeadlessWebContentsImpl* contents_impl =
293 HeadlessWebContentsImpl::From(web_contents);
294 EXPECT_TRUE(contents_impl->web_contents()
295 ->GetRenderViewHost()
296 ->GetWebkitPreferences().hide_scrollbars);
297 }
298
270 } // namespace headless 299 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_content_browser_client.cc ('k') | headless/public/headless_browser_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698