Commit 29a5178c authored by Tatiana Buldina's avatar Tatiana Buldina Committed by Commit Bot

Revert "[ChromeDriver] Do not return stale window handle"

This reverts commit 6a308947.

Reason for revert: Caused https://crbug.com/chromedriver/2615

Original change's description:
> [ChromeDriver] Do not return stale window handle
>
> Move ExecuteGetCurrentWindowHandle() from session_commands.cc
> to window_commands.cc, to make use of automatic window state
> validation done for window commands.
>
> Bug: chromedriver:1404
> Change-Id: Id5ac4c7cea5323f12612b2dfb4dff2b819ce22ff
> Reviewed-on: https://chromium-review.googlesource.com/1257362
> Reviewed-by: John Chen <johnchen@chromium.org>
> Commit-Queue: Tatiana Buldina <buldina@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#595938}

TBR=johnchen@chromium.org,buldina@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: chromedriver:1404 chromedriver:2615
Change-Id: I7b8605d8f83536e0ebcdae4fe8f628fe1de80d1b
Reviewed-on: https://chromium-review.googlesource.com/c/1289069Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600857}
parent fdbd072f
......@@ -59,6 +59,10 @@ const int k2GThroughput = 250 * 1024;
const char kWindowHandlePrefix[] = "CDwindow-";
std::string WebViewIdToWindowHandle(const std::string& web_view_id) {
return kWindowHandlePrefix + web_view_id;
}
bool WindowHandleToWebViewId(const std::string& window_handle,
std::string* web_view_id) {
if (!base::StartsWith(window_handle, kWindowHandlePrefix,
......@@ -83,10 +87,6 @@ Status EvaluateScriptAndIgnoreResult(Session* session, std::string expression) {
} // namespace
std::string WebViewIdToWindowHandle(const std::string& web_view_id) {
return kWindowHandlePrefix + web_view_id;
}
InitSessionParams::InitSessionParams(
scoped_refptr<URLRequestContextGetter> context_getter,
const SyncWebSocketFactory& socket_factory,
......@@ -467,6 +467,18 @@ Status ExecuteGetSessionCapabilities(Session* session,
return Status(kOk);
}
Status ExecuteGetCurrentWindowHandle(Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value) {
WebView* web_view = NULL;
Status status = session->GetTargetWindow(&web_view);
if (status.IsError())
return status;
value->reset(new base::Value(WebViewIdToWindowHandle(web_view->GetId())));
return Status(kOk);
}
Status ExecuteLaunchApp(Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value) {
......
......@@ -43,8 +43,6 @@ bool MatchCapabilities(const base::DictionaryValue* capabilities);
Status ProcessCapabilities(const base::DictionaryValue& params,
base::DictionaryValue* result_capabilities);
std::string WebViewIdToWindowHandle(const std::string& web_view_id);
// Initializes a session.
Status ExecuteInitSession(const InitSessionParams& bound_params,
Session* session,
......@@ -62,6 +60,11 @@ Status ExecuteGetSessionCapabilities(Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value);
// Retrieve the handle of the target window.
Status ExecuteGetCurrentWindowHandle(Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value);
// Close the target window.
Status ExecuteClose(Session* session,
const base::DictionaryValue& params,
......
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "chrome/test/chromedriver/window_commands.h"
#include "chrome/test/chromedriver/session_commands.h"
#include <stddef.h>
......@@ -1581,12 +1580,3 @@ Status ExecuteTakeHeapSnapshot(Session* session,
Timeout* timeout) {
return web_view->TakeHeapSnapshot(value);
}
Status ExecuteGetCurrentWindowHandle(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout) {
value->reset(new base::Value(WebViewIdToWindowHandle(web_view->GetId())));
return Status(kOk);
}
......@@ -365,12 +365,4 @@ Status ExecutePerformActions(Session* session,
Status ProcessInputActionSequence(Session* session,
const base::DictionaryValue* action_sequence,
std::unique_ptr<base::ListValue>* result);
// Retrieve the handle of the target window.
Status ExecuteGetCurrentWindowHandle(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
#endif // CHROME_TEST_CHROMEDRIVER_WINDOW_COMMANDS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment