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 |