Diff
Modified: trunk/Source/WebDriver/ChangeLog (234835 => 234836)
--- trunk/Source/WebDriver/ChangeLog 2018-08-14 05:55:10 UTC (rev 234835)
+++ trunk/Source/WebDriver/ChangeLog 2018-08-14 06:49:25 UTC (rev 234836)
@@ -1,3 +1,24 @@
+2018-08-13 Carlos Garcia Campos <[email protected]>
+
+ WebDriver: several element_send_keys tests are failing since added
+ https://bugs.webkit.org/show_bug.cgi?id=181644
+
+ Reviewed by Michael Catanzaro.
+
+ This is because we are implementing an old version of the spec that received a "value" parameter to send keys
+ command, instead of the "text" one.
+
+ 14.3 Element Send Keys
+ https://w3c.github.io/webdriver/#element-send-keys
+
+ * Session.cpp:
+ (WebDriver::Session::virtualKeyForKey): Receive a single character instead of a sequence.
+ (WebDriver::Session::elementSendKeys): It now receives a String and passes every character to virtualKeyForKey.
+ (WebDriver::Session::performActions): Pass first character of sequence to virtualKeyForKey.
+ * Session.h:
+ * WebDriverService.cpp:
+ (WebDriver::WebDriverService::elementSendKeys): Get text as a String, instead of value as an array.
+
2018-08-12 Carlos Garcia Campos <[email protected]>
WebDriver: do not handle prompts that appear while running scripts
Modified: trunk/Source/WebDriver/Session.cpp (234835 => 234836)
--- trunk/Source/WebDriver/Session.cpp 2018-08-14 05:55:10 UTC (rev 234835)
+++ trunk/Source/WebDriver/Session.cpp 2018-08-14 06:49:25 UTC (rev 234836)
@@ -1579,12 +1579,12 @@
});
}
-String Session::virtualKeyForKeySequence(const String& keySequence, KeyModifier& modifier)
+String Session::virtualKeyForKey(UChar key, KeyModifier& modifier)
{
// ยง17.4.2 Keyboard Actions.
// https://www.w3.org/TR/webdriver/#keyboard-actions
modifier = KeyModifier::None;
- switch (keySequence[0]) {
+ switch (key) {
case 0xE001U:
return "Cancel"_s;
case 0xE002U:
@@ -1717,7 +1717,7 @@
return String();
}
-void Session::elementSendKeys(const String& elementID, Vector<String>&& keys, Function<void (CommandResult&&)>&& completionHandler)
+void Session::elementSendKeys(const String& elementID, const String& text, Function<void (CommandResult&&)>&& completionHandler)
{
if (!m_toplevelBrowsingContext) {
completionHandler(CommandResult::fail(CommandResult::ErrorCode::NoSuchWindow));
@@ -1724,7 +1724,7 @@
return;
}
- handleUserPrompts([this, elementID, keys = WTFMove(keys), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
+ handleUserPrompts([this, elementID, text, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
if (result.isError()) {
completionHandler(WTFMove(result));
return;
@@ -1751,7 +1751,7 @@
parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
parameters->setString("function"_s, focusScript);
parameters->setArray("arguments"_s, WTFMove(arguments));
- m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [this, protectedThis = makeRef(*this), keys = WTFMove(keys), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) mutable {
+ m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [this, protectedThis = makeRef(*this), text, completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) mutable {
if (response.isError || !response.responseObject) {
completionHandler(CommandResult::fail(WTFMove(response.responseObject)));
return;
@@ -1758,12 +1758,14 @@
}
unsigned stickyModifiers = 0;
+ auto textLength = text.length();
Vector<KeyboardInteraction> interactions;
- interactions.reserveInitialCapacity(keys.size());
- for (const auto& key : keys) {
+ interactions.reserveInitialCapacity(textLength);
+ for (unsigned i = 0; i < textLength; ++i) {
+ auto key = text[i];
KeyboardInteraction interaction;
KeyModifier modifier;
- auto virtualKey = virtualKeyForKeySequence(key, modifier);
+ auto virtualKey = virtualKeyForKey(key, modifier);
if (!virtualKey.isNull()) {
interaction.key = virtualKey;
if (modifier != KeyModifier::None) {
@@ -1774,7 +1776,7 @@
interaction.type = KeyboardInteractionType::KeyRelease;
}
} else
- interaction.text = key;
+ interaction.text = String(&key, 1);
interactions.uncheckedAppend(WTFMove(interaction));
}
@@ -2299,7 +2301,7 @@
break;
case Action::Subtype::KeyDown: {
KeyModifier modifier;
- auto virtualKey = virtualKeyForKeySequence(action.key.value(), modifier);
+ auto virtualKey = virtualKeyForKey(action.key.value()[0], modifier);
if (!virtualKey.isNull())
currentState.pressedVirtualKey = virtualKey;
else
Modified: trunk/Source/WebDriver/Session.h (234835 => 234836)
--- trunk/Source/WebDriver/Session.h 2018-08-14 05:55:10 UTC (rev 234835)
+++ trunk/Source/WebDriver/Session.h 2018-08-14 06:49:25 UTC (rev 234836)
@@ -106,7 +106,7 @@
void isElementDisplayed(const String& elementID, Function<void (CommandResult&&)>&&);
void elementClick(const String& elementID, Function<void (CommandResult&&)>&&);
void elementClear(const String& elementID, Function<void (CommandResult&&)>&&);
- void elementSendKeys(const String& elementID, Vector<String>&& keys, Function<void (CommandResult&&)>&&);
+ void elementSendKeys(const String& elementID, const String& text, Function<void (CommandResult&&)>&&);
void executeScript(const String& script, RefPtr<JSON::Array>&& arguments, ExecuteScriptMode, Function<void (CommandResult&&)>&&);
void getAllCookies(Function<void (CommandResult&&)>&&);
void getNamedCookie(const String& name, Function<void (CommandResult&&)>&&);
@@ -184,7 +184,7 @@
Alternate = 1 << 2,
Meta = 1 << 3,
};
- String virtualKeyForKeySequence(const String& keySequence, KeyModifier&);
+ String virtualKeyForKey(UChar, KeyModifier&);
void performKeyboardInteractions(Vector<KeyboardInteraction>&&, Function<void (CommandResult&&)>&&);
struct InputSourceState {
Modified: trunk/Source/WebDriver/WebDriverService.cpp (234835 => 234836)
--- trunk/Source/WebDriver/WebDriverService.cpp 2018-08-14 05:55:10 UTC (rev 234835)
+++ trunk/Source/WebDriver/WebDriverService.cpp 2018-08-14 06:49:25 UTC (rev 234836)
@@ -1393,32 +1393,13 @@
if (!elementID)
return;
- RefPtr<JSON::Array> valueArray;
- if (!parameters->getArray("value"_s, valueArray)) {
+ String text;
+ if (!parameters->getString("text"_s, text) || text.isEmpty()) {
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
return;
}
- unsigned valueArrayLength = valueArray->length();
- if (!valueArrayLength) {
- completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
- return;
- }
- Vector<String> value;
- value.reserveInitialCapacity(valueArrayLength);
- for (unsigned i = 0; i < valueArrayLength; ++i) {
- if (auto keyValue = valueArray->get(i)) {
- String key;
- if (keyValue->asString(key))
- value.uncheckedAppend(WTFMove(key));
- }
- }
- if (!value.size()) {
- completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
- return;
- }
-
- m_session->elementSendKeys(elementID.value(), WTFMove(value), WTFMove(completionHandler));
+ m_session->elementSendKeys(elementID.value(), text, WTFMove(completionHandler));
}
static bool findScriptAndArgumentsOrCompleteWithError(JSON::Object& parameters, Function<void (CommandResult&&)>& completionHandler, String& script, RefPtr<JSON::Array>& arguments)
Modified: trunk/WebDriverTests/ChangeLog (234835 => 234836)
--- trunk/WebDriverTests/ChangeLog 2018-08-14 05:55:10 UTC (rev 234835)
+++ trunk/WebDriverTests/ChangeLog 2018-08-14 06:49:25 UTC (rev 234836)
@@ -1,3 +1,14 @@
+2018-08-13 Carlos Garcia Campos <[email protected]>
+
+ WebDriver: several element_send_keys tests are failing since added
+ https://bugs.webkit.org/show_bug.cgi?id=181644
+
+ Reviewed by Michael Catanzaro.
+
+ Update text expectations.
+
+ * TestExpectations.json:
+
2018-08-12 Michael Catanzaro <[email protected]>
Unreviewed GTK test gardening
Modified: trunk/WebDriverTests/TestExpectations.json (234835 => 234836)
--- trunk/WebDriverTests/TestExpectations.json 2018-08-14 05:55:10 UTC (rev 234835)
+++ trunk/WebDriverTests/TestExpectations.json 2018-08-14 06:49:25 UTC (rev 234836)
@@ -585,12 +585,6 @@
"imported/w3c/webdriver/tests/element_send_keys/form_controls.py": {
"expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/182331"}}
},
- "imported/w3c/webdriver/tests/element_send_keys/interactability.py": {
- "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/181644"}}
- },
- "imported/w3c/webdriver/tests/element_send_keys/scroll_into_view.py": {
- "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/181644"}}
- },
"imported/w3c/webdriver/tests/execute_script/collections.py": {
"subtests": {
"test_arguments": {