Commit 3f54ff21 authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Add Release Actions endpoint

Add Release Actions endpoint as required by W3C spec, and connects the
endpoint to a partial implementation, which doesn't yet include the
processing of input cancel list.

Bug: chromedriver:1897
Change-Id: I8c00c6b76233ef325d562c3a5c123f5e94276064
Reviewed-on: https://chromium-review.googlesource.com/c/1357840Reviewed-by: default avatarCaleb Rouleau <crouleau@chromium.org>
Reviewed-by: default avatarLan Wei <lanwei@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613185}
parent 32ba6d46
......@@ -457,6 +457,9 @@ class ChromeDriver(object):
"""
self.ExecuteCommand(Command.PERFORM_ACTIONS, actions)
def ReleaseActions(self):
self.ExecuteCommand(Command.RELEASE_ACTIONS)
def GetCookies(self):
return self.ExecuteCommand(Command.GET_COOKIES)
......
......@@ -160,6 +160,7 @@ class Command(object):
TOUCH_LONG_PRESS = (_Method.POST, '/session/:sessionId/touch/longclick')
TOUCH_FLICK = (_Method.POST, '/session/:sessionId/touch/flick')
PERFORM_ACTIONS = (_Method.POST, '/session/:sessionId/actions')
RELEASE_ACTIONS = (_Method.DELETE, '/session/:sessionId/actions')
GET_LOG = (_Method.POST, '/session/:sessionId/log')
GET_AVAILABLE_LOG_TYPES = (_Method.GET, '/session/:sessionId/log/types')
IS_AUTO_REPORTING = (_Method.GET, '/session/:sessionId/autoreport')
......
......@@ -78,7 +78,6 @@ _COMMANDS = {
"Click": (Method.POST, "/session/:sessionId/click"),
"ClickElement": (Method.POST, "/session/:sessionId/element/:id/click"),
"CloseWindow": (Method.DELETE, "/session/:sessionId/window"),
"DeleteActions": (Method.DELETE, "/session/:sessionId/actions"),
"DeleteAllCookies": (Method.DELETE, "/session/:sessionId/cookie"),
"DeleteCookie": (Method.DELETE, "/session/:sessionId/cookie/:name"),
"DeleteNetworkConditions":
......@@ -179,6 +178,7 @@ _COMMANDS = {
"PerformActions": (Method.POST, "/session/:sessionId/actions"),
"Quit": (Method.DELETE, "/session/:sessionId"),
"Refresh": (Method.POST, "/session/:sessionId/refresh"),
"ReleaseActions": (Method.DELETE, "/session/:sessionId/actions"),
"RemoveLocalStorageItem":
(Method.DELETE, "/session/:sessionId/local_storage/key/:key"),
"RemoveSessionStorageItem":
......
......@@ -319,8 +319,8 @@ HttpHandler::HttpHandler(
base::BindRepeating(&ExecutePerformActions))),
CommandMapping(
kDelete, "session/:sessionId/actions",
WrapToCommand("DeleteActions",
base::BindRepeating(&ExecuteUnimplementedCommand))),
WrapToCommand("ReleaseActions",
base::BindRepeating(&ExecuteReleaseActions))),
CommandMapping(
kPost, "session/:sessionId/alert/dismiss",
......
......@@ -44,8 +44,6 @@ Session::Session(const std::string& id)
detach(false),
force_devtools_screenshot(false),
sticky_modifiers(0),
active_input_sources(std::make_unique<base::ListValue>()),
input_state_table(std::make_unique<base::DictionaryValue>()),
mouse_position(0, 0),
pressed_mouse_button(kNoneMouseButton),
implicit_wait(kDefaultImplicitWaitTimeout),
......@@ -62,8 +60,6 @@ Session::Session(const std::string& id, std::unique_ptr<Chrome> chrome)
force_devtools_screenshot(false),
chrome(std::move(chrome)),
sticky_modifiers(0),
active_input_sources(std::make_unique<base::ListValue>()),
input_state_table(std::make_unique<base::DictionaryValue>()),
mouse_position(0, 0),
pressed_mouse_button(kNoneMouseButton),
implicit_wait(kDefaultImplicitWaitTimeout),
......
......@@ -78,10 +78,10 @@ struct Session {
int sticky_modifiers;
// List of input sources for each active input. Everytime a new input source
// is added, there must be a corresponding entry made in input_state_table.
std::unique_ptr<base::ListValue> active_input_sources;
base::ListValue active_input_sources;
// Map between input id and input source state for the corresponding input
// source. One entry for each item in active_input_sources
std::unique_ptr<base::DictionaryValue> input_state_table;
base::DictionaryValue input_state_table;
// List of |FrameInfo|s for each frame to the current target frame from the
// first frame element in the root document. If target frame is window.top,
// this list will be empty.
......
......@@ -839,8 +839,8 @@ Status ProcessInputActionSequence(
(*action_sequence_result)->SetString("id", id);
bool found = false;
for (size_t i = 0; i < session->active_input_sources->GetSize(); i++) {
session->active_input_sources->GetDictionary(i, &source);
for (size_t i = 0; i < session->active_input_sources.GetSize(); i++) {
session->active_input_sources.GetDictionary(i, &source);
DCHECK(source);
std::string source_id;
......@@ -876,7 +876,7 @@ Status ProcessInputActionSequence(
tmp_source->SetString("pointerType", pointer_type);
}
session->active_input_sources->Append(std::move(tmp_source));
session->active_input_sources.Append(std::move(tmp_source));
base::DictionaryValue tmp_state;
tmp_state.SetString("id", id);
......@@ -903,7 +903,7 @@ Status ProcessInputActionSequence(
tmp_state.SetInteger("x", x);
tmp_state.SetInteger("y", y);
}
session->input_state_table->SetDictionary(
session->input_state_table.SetDictionary(
id, std::make_unique<base::DictionaryValue>(std::move(tmp_state)));
}
......@@ -1180,6 +1180,19 @@ Status ExecutePerformActions(Session* session,
return Status(kOk);
}
Status ExecuteReleaseActions(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout) {
// TODO(https://crbug.com/chromedriver/1897): Process "input cancel list".
session->input_state_table.Clear();
session->active_input_sources.Clear();
return Status(kOk);
}
Status ExecuteSendCommand(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
......
......@@ -367,6 +367,12 @@ Status ProcessInputActionSequence(
const base::DictionaryValue* action_sequence,
std::unique_ptr<base::DictionaryValue>* result);
Status ExecuteReleaseActions(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteGetWindowRect(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
......
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