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

Unified 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, 3 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 | « headless/lib/browser/headless_content_browser_client.cc ('k') | headless/public/headless_browser_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/headless_browser_context_browsertest.cc
diff --git a/headless/lib/headless_browser_context_browsertest.cc b/headless/lib/headless_browser_context_browsertest.cc
index 1c69aa5b94cacf4bc480064319dc3ac28644c20d..49ab195c09404837850f8c4a70dfd52a2eb2fb1e 100644
--- a/headless/lib/headless_browser_context_browsertest.cc
+++ b/headless/lib/headless_browser_context_browsertest.cc
@@ -8,7 +8,10 @@
#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
+#include "headless/lib/browser/headless_web_contents_impl.h"
#include "headless/public/domains/runtime.h"
#include "headless/public/headless_browser.h"
#include "headless/public/headless_browser_context.h"
@@ -267,4 +270,30 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, IncognitoMode) {
EXPECT_TRUE(base::IsDirectoryEmpty(user_data_dir.GetPath()));
}
+IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, ContextWebPreferences) {
+ // By default, hide_scrollbars should be false.
+ EXPECT_FALSE(WebPreferences().hide_scrollbars);
+
+ // Set hide_scrollbars preference to true for a new BrowserContext.
+ HeadlessBrowserContext* browser_context =
+ browser()
+ ->CreateBrowserContextBuilder()
+ .SetOverrideWebPreferencesCallback(
+ base::Bind([](headless::WebPreferences* preferences) {
+ preferences->hide_scrollbars = true;
+ }))
+ .Build();
+ HeadlessWebContents* web_contents =
+ browser_context->CreateWebContentsBuilder()
+ .SetInitialURL(GURL("about:blank"))
+ .Build();
+
+ // Verify that the preference takes effect.
+ HeadlessWebContentsImpl* contents_impl =
+ HeadlessWebContentsImpl::From(web_contents);
+ EXPECT_TRUE(contents_impl->web_contents()
+ ->GetRenderViewHost()
+ ->GetWebkitPreferences().hide_scrollbars);
+}
+
} // namespace headless
« 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