summaryrefslogtreecommitdiffstats
path: root/chrome/test/automation
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-19 17:08:12 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-19 17:08:12 +0000
commit2ce26c438a2cd219348eefa324a64c15d1bf8cf2 (patch)
tree8b17944db4ef181365a7a29d4c86bb96f9a29754 /chrome/test/automation
parent334b47007cdd108b8e0b0566bd29f952f5ad71f8 (diff)
downloadchromium_src-2ce26c438a2cd219348eefa324a64c15d1bf8cf2.zip
chromium_src-2ce26c438a2cd219348eefa324a64c15d1bf8cf2.tar.gz
chromium_src-2ce26c438a2cd219348eefa324a64c15d1bf8cf2.tar.bz2
Wait properly for renderer crashes
This replaces a Sleep in automation with a wait for renderer crash. It turns out that our IPC on POSIX had one loophole that caused it not to notice very early crashes, so I also fixed that. The problem was that when the child process died before connecting to the parent's IPC channel, the parent wouldn't notice the crash because the child end of the IPC pipe was kept open for too long. This change makes the code close the child end of the pipe right after forking the child. This might also help with automation not noticing the browser crash during initial launch, or at least should be a good step toward fixing that problem. BUG=38497,90489 Review URL: http://codereview.chromium.org/7870008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101760 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
-rw-r--r--chrome/test/automation/automation_proxy.cc12
-rw-r--r--chrome/test/automation/automation_proxy.h4
-rw-r--r--chrome/test/automation/proxy_launcher.cc31
-rw-r--r--chrome/test/automation/proxy_launcher.h1
4 files changed, 24 insertions, 24 deletions
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index 4704deb..10bcf6d 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -432,15 +432,9 @@ scoped_refptr<BrowserProxy> AutomationProxy::GetLastActiveBrowserWindow() {
return ProxyObjectFromHandle<BrowserProxy>(handle);
}
-#if defined(OS_POSIX)
-base::file_handle_mapping_vector AutomationProxy::fds_to_map() const {
- base::file_handle_mapping_vector map;
- const int ipcfd = channel_->GetClientFileDescriptor();
- if (ipcfd > -1)
- map.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3));
- return map;
-}
-#endif // defined(OS_POSIX)
+IPC::SyncChannel* AutomationProxy::channel() {
+ return channel_.get();
+}
bool AutomationProxy::Send(IPC::Message* message) {
return Send(message,
diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h
index a41689d..0fccd90 100644
--- a/chrome/test/automation/automation_proxy.h
+++ b/chrome/test/automation/automation_proxy.h
@@ -222,9 +222,7 @@ class AutomationProxy : public IPC::Channel::Listener,
const std::string& password) WARN_UNUSED_RESULT;
#endif
-#if defined(OS_POSIX)
- base::file_handle_mapping_vector fds_to_map() const;
-#endif
+ IPC::SyncChannel* channel();
// AutomationMessageSender implementation.
virtual bool Send(IPC::Message* message) WARN_UNUSED_RESULT;
diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc
index 34c4060..469a0f2 100644
--- a/chrome/test/automation/proxy_launcher.cc
+++ b/chrome/test/automation/proxy_launcher.cc
@@ -26,6 +26,7 @@
#include "content/common/child_process_info.h"
#include "content/common/debug_flags.h"
#include "ipc/ipc_channel.h"
+#include "ipc/ipc_descriptors.h"
#include "sql/connection.h"
namespace {
@@ -109,11 +110,11 @@ bool ProxyLauncher::WaitForBrowserLaunch(bool wait_for_initial_loads) {
return false;
}
} else {
- // TODO(phajdan.jr): We should get rid of this sleep, but some tests
- // "rely" on it, e.g. AssertionTest.Assertion and CheckFalseTest.CheckFails.
- // Those tests do not wait in any way until the crash gets noticed,
- // so it's possible for the browser to exit before the tested crash happens.
+#if defined(OS_WIN)
+ // TODO(phajdan.jr): Get rid of this Sleep when logging_chrome_uitest
+ // stops "relying" on it.
base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms());
+#endif
}
if (!automation()->SetFilteredInet(ShouldFilterInet())) {
@@ -198,7 +199,7 @@ bool ProxyLauncher::LaunchBrowser(const LaunchState& state) {
if (!state.setup_profile_callback.is_null())
state.setup_profile_callback.Run();
- if (!LaunchBrowserHelper(state, false, &process_)) {
+ if (!LaunchBrowserHelper(state, true, false, &process_)) {
LOG(ERROR) << "LaunchBrowserHelper failed.";
return false;
}
@@ -210,7 +211,7 @@ bool ProxyLauncher::LaunchBrowser(const LaunchState& state) {
#if !defined(OS_MACOSX)
bool ProxyLauncher::LaunchAnotherBrowserBlockUntilClosed(
const LaunchState& state) {
- return LaunchBrowserHelper(state, true, NULL);
+ return LaunchBrowserHelper(state, false, true, NULL);
}
#endif
@@ -435,7 +436,9 @@ void ProxyLauncher::PrepareTestCommandline(CommandLine* command_line,
command_line->AppendSwitch(switches::kUnlimitedQuotaForFiles);
}
-bool ProxyLauncher::LaunchBrowserHelper(const LaunchState& state, bool wait,
+bool ProxyLauncher::LaunchBrowserHelper(const LaunchState& state,
+ bool main_launch,
+ bool wait,
base::ProcessHandle* process) {
CommandLine command_line(state.command);
@@ -459,8 +462,8 @@ bool ProxyLauncher::LaunchBrowserHelper(const LaunchState& state, bool wait,
<< browser_wrapper;
}
- // TODO(phajdan.jr): Only run it for "main" browser launch.
- browser_launch_time_ = base::TimeTicks::Now();
+ if (main_launch)
+ browser_launch_time_ = base::TimeTicks::Now();
base::LaunchOptions options;
options.wait = wait;
@@ -468,10 +471,14 @@ bool ProxyLauncher::LaunchBrowserHelper(const LaunchState& state, bool wait,
#if defined(OS_WIN)
options.start_hidden = !state.show_window;
#elif defined(OS_POSIX)
+ int ipcfd = -1;
+ file_util::ScopedFD ipcfd_closer(&ipcfd);
base::file_handle_mapping_vector fds;
- if (automation_proxy_.get())
- fds = automation_proxy_->fds_to_map();
- options.fds_to_remap = &fds;
+ if (main_launch && automation_proxy_.get()) {
+ ipcfd = automation_proxy_->channel()->TakeClientFileDescriptor();
+ fds.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3));
+ options.fds_to_remap = &fds;
+ }
#endif
return base::LaunchProcess(command_line, options, process);
diff --git a/chrome/test/automation/proxy_launcher.h b/chrome/test/automation/proxy_launcher.h
index 0e497b7..64f5b2b 100644
--- a/chrome/test/automation/proxy_launcher.h
+++ b/chrome/test/automation/proxy_launcher.h
@@ -166,6 +166,7 @@ class ProxyLauncher {
bool include_testing_id);
bool LaunchBrowserHelper(const LaunchState& state,
+ bool main_launch,
bool wait,
base::ProcessHandle* process) WARN_UNUSED_RESULT;