Index: chrome/test/webdriver/webdriver_session.cc |
diff --git a/chrome/test/webdriver/webdriver_session.cc b/chrome/test/webdriver/webdriver_session.cc |
index 74ad4a1877e7c5f5144366045af59f52248022df..c1c152467cf5f112ea9fc563227da65d34ebf0fd 100644 |
--- a/chrome/test/webdriver/webdriver_session.cc |
+++ b/chrome/test/webdriver/webdriver_session.cc |
@@ -67,6 +67,7 @@ Session::Session(const Options& options) |
async_script_timeout_(0), |
implicit_wait_(0), |
has_alert_prompt_text_(false), |
+ terminated_(false), |
options_(options) { |
SessionManager::GetInstance()->Add(this); |
} |
@@ -93,6 +94,8 @@ Error* Session::Init(const Automation::BrowserOptions& options) { |
} |
Error* Session::BeforeExecuteCommand() { |
+ if (terminated_) |
+ return NULL; |
Error* error = AfterExecuteCommand(); |
if (!error) { |
scoped_ptr<Error> switch_error(SwitchToTopFrameIfCurrentFrameInvalid()); |
@@ -110,6 +113,8 @@ Error* Session::BeforeExecuteCommand() { |
} |
Error* Session::AfterExecuteCommand() { |
+ if (terminated_) |
+ return NULL; |
Error* error = NULL; |
if (!options_.load_async) { |
LOG(INFO) << "Waiting for the page to stop loading"; |
@@ -120,6 +125,7 @@ Error* Session::AfterExecuteCommand() { |
} |
void Session::Terminate() { |
+ terminated_ = true; |
RunSessionTask(NewRunnableMethod( |
this, |
&Session::TerminateOnSessionThread)); |