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

Unified Diff: chrome/test/chromedriver/session_command.cc

Issue 12226026: [ChromeDriver] Select the main frame if a non-existant child frame is targeted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: watch for message and make test non-racey Created 7 years, 10 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
Index: chrome/test/chromedriver/session_command.cc
diff --git a/chrome/test/chromedriver/session_command.cc b/chrome/test/chromedriver/session_command.cc
index 439ce20a2d2163bdec3b0b7a3fbd64afcdcf6247..06bc07d73fb5ce1e64dde7251a34a0fc99124c49 100644
--- a/chrome/test/chromedriver/session_command.cc
+++ b/chrome/test/chromedriver/session_command.cc
@@ -13,22 +13,6 @@
#include "chrome/test/chromedriver/session_map.h"
#include "chrome/test/chromedriver/status.h"
-namespace {
-
-Status WaitForPendingNavigations(const Session& session) {
- if (!session.chrome)
- return Status(kOk);
- std::string frame = session.frame;
- if (frame == "") {
- Status status = session.chrome->GetMainFrame(&frame);
- if (status.IsError())
- return status;
- }
- return session.chrome->WaitForPendingNavigations(frame);
-}
-
-} // namespace
-
Status ExecuteSessionCommand(
SessionMap* session_map,
const SessionCommand& command,
@@ -45,11 +29,19 @@ Status ExecuteSessionCommand(
if (!session)
return Status(kNoSuchSession, session_id);
- Status nav_status = WaitForPendingNavigations(*session);
+ Status nav_status = session->WaitForPendingNavigations();
if (nav_status.IsError())
return nav_status;
Status status = command.Run(session, params, out_value);
- nav_status = WaitForPendingNavigations(*session);
+ // Switch to main frame and retry command if subframe no longer exists.
+ if (status.code() == kNoSuchFrame) {
kkania 2013/02/06 23:45:26 I'm worried this might not be correct for all circ
craigdh 2013/02/07 00:05:37 When the inevitable bugs raise their heads assign
+ session->frame = "";
+ nav_status = session->WaitForPendingNavigations();
+ if (nav_status.IsError())
+ return nav_status;
+ status = command.Run(session, params, out_value);
+ }
+ nav_status = session->WaitForPendingNavigations();
if (status.IsOk() && nav_status.IsError() &&
nav_status.code() != kDisconnected)
return nav_status;

Powered by Google App Engine
This is Rietveld 408576698