Commit 9bcb9368 authored by Tatiana Buldina's avatar Tatiana Buldina Committed by Commit Bot

[ChromeDriver] Fix WPT test test_not_editable_inputs[hidden]

Update ExecuteClearElement() to check element type and state
and throw kInvalidElementState if they are incorrect

Bug: chromedriver:3005
Change-Id: I0ee8a35767113b1a9dc9bee29687290ae7325161
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832664Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Tatiana Buldina <buldina@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705138}
parent b25705ee
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
const int kFlickTouchEventsPerSecond = 30; const int kFlickTouchEventsPerSecond = 30;
const std::set<std::string> textControlTypes = {"text", "search", "tel", "url", const std::set<std::string> textControlTypes = {"text", "search", "tel", "url",
"password"}; "password"};
const std::set<std::string> inputControlTypes = {
"text", "search", "url", "tel", "email",
"password", "date", "month", "week", "time",
"datetime-local", "number", "range", "color", "file"};
namespace { namespace {
...@@ -321,6 +325,56 @@ Status ExecuteClearElement(Session* session, ...@@ -321,6 +325,56 @@ Status ExecuteClearElement(Session* session,
Status status = CheckElement(element_id); Status status = CheckElement(element_id);
if (status.IsError()) if (status.IsError())
return status; return status;
std::string tag_name;
status = GetElementTagName(session, web_view, element_id, &tag_name);
if (status.IsError())
return status;
std::string element_type;
bool is_input_control = false;
if (tag_name == "input") {
std::unique_ptr<base::Value> get_element_type;
status = GetElementAttribute(session, web_view, element_id, "type",
&get_element_type);
if (status.IsError())
return status;
if (get_element_type->GetAsString(&element_type))
element_type = base::ToLowerASCII(element_type);
is_input_control =
inputControlTypes.find(element_type) != inputControlTypes.end();
}
bool is_text = tag_name == "textarea";
bool is_content_editable = false;
if (!is_text && !is_input_control) {
std::unique_ptr<base::Value> get_content_editable;
base::ListValue args;
args.Append(CreateElement(element_id));
status = web_view->CallFunction(session->GetCurrentFrameId(),
"element => element.isContentEditable",
args, &get_content_editable);
if (status.IsError())
return status;
get_content_editable->GetAsBoolean(&is_content_editable);
}
std::unique_ptr<base::Value> get_readonly;
bool is_readonly = false;
base::DictionaryValue params_readOnly;
if (!is_content_editable) {
params_readOnly.SetString("name", "readOnly");
status = ExecuteGetElementProperty(session, web_view, element_id,
params_readOnly, &get_readonly);
get_readonly->GetAsBoolean(&is_readonly);
if (status.IsError())
return status;
}
bool is_editable =
(is_input_control || is_text || is_content_editable) && !is_readonly;
if (!is_editable)
return Status(kInvalidElementState);
// Scrolling to element is done by webdriver::atoms::CLEAR // Scrolling to element is done by webdriver::atoms::CLEAR
bool is_displayed = false; bool is_displayed = false;
base::TimeTicks start_time = base::TimeTicks::Now(); base::TimeTicks start_time = base::TimeTicks::Now();
......
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