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

Unified Diff: chrome/test/webdriver/webdriver_automation.cc

Issue 7648053: [chromedriver] Add chrome.detach option for configuring Chrome not to quit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win compile issue Created 9 years, 4 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 | « chrome/test/webdriver/webdriver_automation.h ('k') | chrome/test/webdriver/webdriver_dispatch.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/webdriver_automation.cc
diff --git a/chrome/test/webdriver/webdriver_automation.cc b/chrome/test/webdriver/webdriver_automation.cc
index f410842a73159193efb8d3d761ff422b6fc92e0a..9d218372a6866442e09f49c86c03154178602e21 100644
--- a/chrome/test/webdriver/webdriver_automation.cc
+++ b/chrome/test/webdriver/webdriver_automation.cc
@@ -184,7 +184,8 @@ bool GetDefaultChromeExe(FilePath* browser_exe) {
namespace webdriver {
Automation::BrowserOptions::BrowserOptions()
- : command(CommandLine::NO_PROGRAM) {}
+ : command(CommandLine::NO_PROGRAM),
+ detach_process(false) {}
Automation::BrowserOptions::~BrowserOptions() {}
@@ -201,6 +202,8 @@ void Automation::Init(const BrowserOptions& options, Error** error) {
command.AppendSwitch(switches::kFullMemoryCrashReport);
command.AppendSwitch(switches::kNoDefaultBrowserCheck);
command.AppendSwitch(switches::kNoFirstRun);
+ if (options.detach_process)
+ command.AppendSwitch(switches::kAutomationReinitializeOnChannelError);
if (options.user_data_dir.empty())
command.AppendSwitchASCII(switches::kHomePage, chrome::kAboutBlankURL);
@@ -228,10 +231,35 @@ void Automation::Init(const BrowserOptions& options, Error** error) {
LOG(INFO) << chrome_details;
// Create the ProxyLauncher and launch Chrome.
- if (options.channel_id.empty()) {
+ // In Chrome 13/14, the only way to detach the browser process is to use a
+ // named proxy launcher.
+ // TODO(kkania): Remove this when Chrome 15 is stable.
+ std::string channel_id = options.channel_id;
+ bool launch_browser = false;
+ if (options.detach_process) {
+ launch_browser = true;
+ if (!channel_id.empty()) {
+ *error = new Error(
+ kUnknownError, "Cannot detach an already running browser process");
+ return;
+ }
+#if defined(OS_WIN)
+ channel_id = "chromedriver" + GenerateRandomID();
+#elif defined(OS_POSIX)
+ FilePath temp_file;
+ if (!file_util::CreateTemporaryFile(&temp_file) ||
+ !file_util::Delete(temp_file, false /* recursive */)) {
+ *error = new Error(kUnknownError, "Could not create temporary filename");
+ return;
+ }
+ channel_id = temp_file.value();
+#endif
+ }
+ if (channel_id.empty()) {
launcher_.reset(new AnonymousProxyLauncher(false));
} else {
- launcher_.reset(new NamedProxyLauncher(options.channel_id, false, false));
+ LOG(INFO) << "Using named testing interface";
+ launcher_.reset(new NamedProxyLauncher(channel_id, launch_browser, false));
}
ProxyLauncher::LaunchState launch_props = {
false, // clear_profile
« no previous file with comments | « chrome/test/webdriver/webdriver_automation.h ('k') | chrome/test/webdriver/webdriver_dispatch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698