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

Unified Diff: headless/lib/headless_browser_browsertest.cc

Issue 2389803002: headless: Add a test for --renderer-cmd-prefix (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/headless_browser_browsertest.cc
diff --git a/headless/lib/headless_browser_browsertest.cc b/headless/lib/headless_browser_browsertest.cc
index 39525c9be3bbb90ea79892feaaf149703dfa2929..bd28321b2d0b73a8426840294907568479834366 100644
--- a/headless/lib/headless_browser_browsertest.cc
+++ b/headless/lib/headless_browser_browsertest.cc
@@ -4,6 +4,8 @@
#include <memory>
+#include "base/command_line.h"
+#include "base/files/file_util.h"
#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "content/public/test/browser_test.h"
@@ -593,4 +595,49 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, SetCookiesWithDevTools) {
EXPECT_EQ("oblong", sent_cookies[0].Value());
}
+// TODO(skyostil): This test currently relies on being able to run a shell
+// script.
+#if defined(OS_POSIX)
+#define MAYBE_RendererCommandPrefixTest RendererCommandPrefixTest
+#else
+#define MAYBE_RendererCommandPrefixTest DISABLED_RendererCommandPrefixTest
+#endif // defined(OS_POSIX)
+IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, MAYBE_RendererCommandPrefixTest) {
+ base::FilePath launcher_stamp;
+ base::CreateTemporaryFile(&launcher_stamp);
+
+ base::FilePath launcher_script;
+ FILE* launcher_file = base::CreateAndOpenTemporaryFile(&launcher_script);
+ fprintf(launcher_file, "#!/bin/sh\n");
+ fprintf(launcher_file, "echo $@ > %s\n", launcher_stamp.value().c_str());
+ fprintf(launcher_file, "exec $@\n");
+ fclose(launcher_file);
+ base::SetPosixFilePermissions(launcher_script,
+ base::FILE_PERMISSION_READ_BY_USER |
+ base::FILE_PERMISSION_EXECUTE_BY_USER);
+
+ base::CommandLine::ForCurrentProcess()->AppendSwitch("--no-sandbox");
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ "--renderer-cmd-prefix", launcher_script.value());
+
+ EXPECT_TRUE(embedded_test_server()->Start());
+
+ HeadlessBrowserContext* browser_context =
+ browser()->CreateBrowserContextBuilder().Build();
+
+ HeadlessWebContents* web_contents =
+ browser_context->CreateWebContentsBuilder()
+ .SetInitialURL(embedded_test_server()->GetURL("/hello.html"))
+ .Build();
+ EXPECT_TRUE(WaitForLoad(web_contents));
+
+ // Make sure the launcher was invoked when starting the renderer.
+ std::string stamp;
+ EXPECT_TRUE(base::ReadFileToString(launcher_stamp, &stamp));
+ EXPECT_GE(stamp.find("--type=renderer"), 0u);
+
+ base::DeleteFile(launcher_script, false);
+ base::DeleteFile(launcher_stamp, false);
+}
+
} // namespace headless
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698