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

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

Issue 1004333002: [chromedriver] Add a sanity check during session initiation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 5 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/session_commands.cc
diff --git a/chrome/test/chromedriver/session_commands.cc b/chrome/test/chromedriver/session_commands.cc
index 9af15c3a49f51164d7b480df0a1c6d5f13448759..1591d69ac08fa53bfb1eddbbb78f0aa53af7615e 100644
--- a/chrome/test/chromedriver/session_commands.cc
+++ b/chrome/test/chromedriver/session_commands.cc
@@ -105,6 +105,32 @@ scoped_ptr<base::DictionaryValue> CreateCapabilities(Chrome* chrome) {
return caps.Pass();
}
+Status CheckSessionCreated(Session* session) {
+ WebView* web_view = NULL;
+ Status status = session->GetTargetWindow(&web_view);
+ if (status.IsError())
+ return Status(kSessionNotCreatedException, status);
+
+ status = web_view->ConnectIfNecessary();
+ if (status.IsError())
+ return Status(kSessionNotCreatedException, status);
+
+ base::ListValue args;
+ scoped_ptr<base::Value> result(new base::FundamentalValue(0));
+ status = web_view->CallFunction(session->GetCurrentFrameId(),
+ "function(s) { return 1; }", args, &result);
+ if (status.IsError())
+ return Status(kSessionNotCreatedException, status);
+
+ int response;
+ if (!result->GetAsInteger(&response) || response != 1) {
+ return Status(kSessionNotCreatedException,
+ "unexpected response from browser");
+ }
+
+ return Status(kOk);
+}
+
Status InitSessionHelper(
const InitSessionParams& bound_params,
Session* session,
@@ -165,7 +191,7 @@ Status InitSessionHelper(
session->force_devtools_screenshot = capabilities.force_devtools_screenshot;
session->capabilities = CreateCapabilities(session->chrome.get());
value->reset(session->capabilities->DeepCopy());
- return Status(kOk);
+ return CheckSessionCreated(session);
}
} // namespace
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698