| Index: chrome/test/chromedriver/window_commands.cc
|
| diff --git a/chrome/test/chromedriver/window_commands.cc b/chrome/test/chromedriver/window_commands.cc
|
| index 54dca1e590cc7a28603a83d5911204e9ef1ce1eb..36a13984eb9e4f7988cb27b3f12d26af06bb9fc6 100644
|
| --- a/chrome/test/chromedriver/window_commands.cc
|
| +++ b/chrome/test/chromedriver/window_commands.cc
|
| @@ -17,6 +17,7 @@
|
| #include "chrome/test/chromedriver/session.h"
|
| #include "chrome/test/chromedriver/status.h"
|
| #include "chrome/test/chromedriver/ui_events.h"
|
| +#include "chrome/test/chromedriver/util.h"
|
| #include "chrome/test/chromedriver/web_view.h"
|
|
|
| namespace {
|
| @@ -144,7 +145,7 @@ Status ExecuteWindowCommand(
|
| status = command.Run(session, web_view, params, value);
|
| // Switch to main frame and retry command if subframe no longer exists.
|
| if (status.code() == kNoSuchFrame) {
|
| - session->frame = "";
|
| + session->SetToFrame("", "");
|
| nav_status = web_view->WaitForPendingNavigations(session->frame);
|
| if (nav_status.IsError())
|
| return nav_status;
|
| @@ -194,7 +195,7 @@ Status ExecuteSwitchToFrame(
|
| return Status(kUnknownError, "missing 'id'");
|
|
|
| if (id->IsType(base::Value::TYPE_NULL)) {
|
| - session->frame = "";
|
| + session->SetToFrame("", "");
|
| return Status(kOk);
|
| }
|
|
|
| @@ -228,7 +229,31 @@ Status ExecuteSwitchToFrame(
|
| session->frame, script, args, &frame);
|
| if (status.IsError())
|
| return status;
|
| - session->frame = frame;
|
| +
|
| + scoped_ptr<base::Value> result;
|
| + status = web_view->CallFunction(
|
| + session->frame, script, args, &result);
|
| + if (status.IsError())
|
| + return status;
|
| + const base::DictionaryValue* element;
|
| + if (!result->GetAsDictionary(&element))
|
| + return Status(kUnknownError, "fail to locate the sub frame element");
|
| +
|
| + std::string fake_id = GenerateId();
|
| + const char* kSetFrameIdentifier =
|
| + "function(frame, id) {"
|
| + " frame.setAttribute('cd_frame_id_', id);"
|
| + "}";
|
| + base::ListValue new_args;
|
| + new_args.Append(element->DeepCopy());
|
| + new_args.AppendString(fake_id);
|
| + result.reset(NULL);
|
| + status = web_view->CallFunction(
|
| + session->frame, kSetFrameIdentifier, new_args, &result);
|
| + if (status.IsError())
|
| + return status;
|
| + session->SetToFrame(
|
| + frame, base::StringPrintf("//*[@cd_frame_id_ = '%s']", fake_id.c_str()));
|
| return Status(kOk);
|
| }
|
|
|
| @@ -342,13 +367,13 @@ Status ExecuteMouseMoveTo(
|
| }
|
|
|
| if (has_offset) {
|
| - location.offset(x_offset, y_offset);
|
| + location.Offset(x_offset, y_offset);
|
| } else {
|
| WebSize size;
|
| Status status = GetElementSize(session, web_view, element_id, &size);
|
| if (status.IsError())
|
| return status;
|
| - location.offset(size.width / 2, size.height / 2);
|
| + location.Offset(size.width / 2, size.height / 2);
|
| }
|
|
|
| std::list<MouseEvent> events;
|
|
|