Index: chrome/test/webdriver/webdriver_session.cc |
diff --git a/chrome/test/webdriver/webdriver_session.cc b/chrome/test/webdriver/webdriver_session.cc |
index efd7b1ef6e6d651550b9e9430c5937a893250ee3..f93ed46eda50406bec4d3bfed862f9783131121a 100644 |
--- a/chrome/test/webdriver/webdriver_session.cc |
+++ b/chrome/test/webdriver/webdriver_session.cc |
@@ -93,15 +93,29 @@ Error* Session::Init(const Automation::BrowserOptions& options) { |
} |
Error* Session::BeforeExecuteCommand() { |
+ Error* error = AfterExecuteCommand(); |
+ if (!error) { |
+ scoped_ptr<Error> switch_error(SwitchToTopFrameIfCurrentFrameInvalid()); |
+ if (switch_error.get()) { |
+ std::string text; |
+ scoped_ptr<Error> alert_error(GetAlertMessage(&text)); |
+ if (alert_error.get()) { |
+ // Only return a frame checking error if a modal dialog is not present. |
+ // TODO(kkania): This is ugly. Fix. |
+ return switch_error.release(); |
+ } |
+ } |
+ } |
+ return error; |
+} |
+ |
+Error* Session::AfterExecuteCommand() { |
Error* error = NULL; |
if (!options_.load_async) { |
LOG(INFO) << "Waiting for the page to stop loading"; |
error = WaitForAllTabsToStopLoading(); |
LOG(INFO) << "Done waiting for the page to stop loading"; |
} |
- if (!error) { |
- error = SwitchToTopFrameIfCurrentFrameInvalid(); |
- } |
return error; |
} |