Chromium Code Reviews| Index: chrome/test/chromedriver/session_commands.cc |
| diff --git a/chrome/test/chromedriver/session_commands.cc b/chrome/test/chromedriver/session_commands.cc |
| index b403124f5d63c31e8d49df11e8063f586ff47d0d..4d8513223a4e579c0582c41dd285be91e8793951 100644 |
| --- a/chrome/test/chromedriver/session_commands.cc |
| +++ b/chrome/test/chromedriver/session_commands.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/logging.h" // For CHECK macros. |
| #include "base/memory/ref_counted.h" |
| #include "base/message_loop/message_loop_proxy.h" |
| +#include "base/strings/stringprintf.h" |
| #include "base/synchronization/lock.h" |
| #include "base/synchronization/waitable_event.h" |
| #include "base/values.h" |
| @@ -105,6 +106,34 @@ 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; |
| + args.AppendString("ping"); |
| + scoped_ptr<base::Value> result(new base::StringValue(std::string())); |
| + status = web_view->CallFunction(session->GetCurrentFrameId(), |
| + "function(s){return s.replace('i','o')}", |
|
stgao
2015/03/14 00:22:03
For the purpose of sanity check, maybe a simple "r
samuong
2015/03/14 17:17:46
Done.
|
| + args, &result); |
| + if (status.IsError()) |
| + return Status(kSessionNotCreatedException, status); |
| + |
| + std::string response; |
| + if (!result->GetAsString(&response) || response != "pong") { |
| + return Status(kSessionNotCreatedException, |
| + base::StringPrintf("unexpected response from browser")); |
|
stgao
2015/03/14 00:22:03
It seems other places use raw strings directly, li
samuong
2015/03/14 17:17:46
Done. It's no longer needed, so I've removed it.
|
| + } |
| + |
| + return Status(kOk); |
| +} |
| + |
| Status InitSessionHelper( |
| const InitSessionParams& bound_params, |
| Session* session, |
| @@ -165,7 +194,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 |