<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[234836] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/234836">234836</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2018-08-13 23:49:25 -0700 (Mon, 13 Aug 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebDriverChangeLog">trunk/Source/WebDriver/ChangeLog</a></li>
<li><a href="#trunkSourceWebDriverSessioncpp">trunk/Source/WebDriver/Session.cpp</a></li>
<li><a href="#trunkSourceWebDriverSessionh">trunk/Source/WebDriver/Session.h</a></li>
<li><a href="#trunkSourceWebDriverWebDriverServicecpp">trunk/Source/WebDriver/WebDriverService.cpp</a></li>
<li><a href="#trunkWebDriverTestsChangeLog">trunk/WebDriverTests/ChangeLog</a></li>
<li><a href="#trunkWebDriverTestsTestExpectationsjson">trunk/WebDriverTests/TestExpectations.json</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebDriverChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebDriver/ChangeLog (234835 => 234836)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2018-08-13  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        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.
+
</ins><span class="cx"> 2018-08-12  Carlos Garcia Campos  <cgarcia@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         WebDriver: do not handle prompts that appear while running scripts
</span></span></pre></div>
<a id="trunkSourceWebDriverSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebDriver/Session.cpp (234835 => 234836)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1579,12 +1579,12 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String Session::virtualKeyForKeySequence(const String& keySequence, KeyModifier& modifier)
</del><ins>+String Session::virtualKeyForKey(UChar key, KeyModifier& modifier)
</ins><span class="cx"> {
</span><span class="cx">     // ยง17.4.2 Keyboard Actions.
</span><span class="cx">     // https://www.w3.org/TR/webdriver/#keyboard-actions
</span><span class="cx">     modifier = KeyModifier::None;
</span><del>-    switch (keySequence[0]) {
</del><ins>+    switch (key) {
</ins><span class="cx">     case 0xE001U:
</span><span class="cx">         return "Cancel"_s;
</span><span class="cx">     case 0xE002U:
</span><span class="lines">@@ -1717,7 +1717,7 @@
</span><span class="cx">     return String();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Session::elementSendKeys(const String& elementID, Vector<String>&& keys, Function<void (CommandResult&&)>&& completionHandler)
</del><ins>+void Session::elementSendKeys(const String& elementID, const String& text, Function<void (CommandResult&&)>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_toplevelBrowsingContext) {
</span><span class="cx">         completionHandler(CommandResult::fail(CommandResult::ErrorCode::NoSuchWindow));
</span><span class="lines">@@ -1724,7 +1724,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    handleUserPrompts([this, elementID, keys = WTFMove(keys), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
</del><ins>+    handleUserPrompts([this, elementID, text, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
</ins><span class="cx">         if (result.isError()) {
</span><span class="cx">             completionHandler(WTFMove(result));
</span><span class="cx">             return;
</span><span class="lines">@@ -1751,7 +1751,7 @@
</span><span class="cx">             parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
</span><span class="cx">         parameters->setString("function"_s, focusScript);
</span><span class="cx">         parameters->setArray("arguments"_s, WTFMove(arguments));
</span><del>-        m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [this, protectedThis = makeRef(*this), keys = WTFMove(keys), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) mutable {
</del><ins>+        m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [this, protectedThis = makeRef(*this), text, completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) mutable {
</ins><span class="cx">             if (response.isError || !response.responseObject) {
</span><span class="cx">                 completionHandler(CommandResult::fail(WTFMove(response.responseObject)));
</span><span class="cx">                 return;
</span><span class="lines">@@ -1758,12 +1758,14 @@
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             unsigned stickyModifiers = 0;
</span><ins>+            auto textLength = text.length();
</ins><span class="cx">             Vector<KeyboardInteraction> interactions;
</span><del>-            interactions.reserveInitialCapacity(keys.size());
-            for (const auto& key : keys) {
</del><ins>+            interactions.reserveInitialCapacity(textLength);
+            for (unsigned i = 0; i < textLength; ++i) {
+                auto key = text[i];
</ins><span class="cx">                 KeyboardInteraction interaction;
</span><span class="cx">                 KeyModifier modifier;
</span><del>-                auto virtualKey = virtualKeyForKeySequence(key, modifier);
</del><ins>+                auto virtualKey = virtualKeyForKey(key, modifier);
</ins><span class="cx">                 if (!virtualKey.isNull()) {
</span><span class="cx">                     interaction.key = virtualKey;
</span><span class="cx">                     if (modifier != KeyModifier::None) {
</span><span class="lines">@@ -1774,7 +1776,7 @@
</span><span class="cx">                             interaction.type = KeyboardInteractionType::KeyRelease;
</span><span class="cx">                     }
</span><span class="cx">                 } else
</span><del>-                    interaction.text = key;
</del><ins>+                    interaction.text = String(&key, 1);
</ins><span class="cx">                 interactions.uncheckedAppend(WTFMove(interaction));
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="lines">@@ -2299,7 +2301,7 @@
</span><span class="cx">                         break;
</span><span class="cx">                     case Action::Subtype::KeyDown: {
</span><span class="cx">                         KeyModifier modifier;
</span><del>-                        auto virtualKey = virtualKeyForKeySequence(action.key.value(), modifier);
</del><ins>+                        auto virtualKey = virtualKeyForKey(action.key.value()[0], modifier);
</ins><span class="cx">                         if (!virtualKey.isNull())
</span><span class="cx">                             currentState.pressedVirtualKey = virtualKey;
</span><span class="cx">                         else
</span></span></pre></div>
<a id="trunkSourceWebDriverSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebDriver/Session.h (234835 => 234836)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx">     void isElementDisplayed(const String& elementID, Function<void (CommandResult&&)>&&);
</span><span class="cx">     void elementClick(const String& elementID, Function<void (CommandResult&&)>&&);
</span><span class="cx">     void elementClear(const String& elementID, Function<void (CommandResult&&)>&&);
</span><del>-    void elementSendKeys(const String& elementID, Vector<String>&& keys, Function<void (CommandResult&&)>&&);
</del><ins>+    void elementSendKeys(const String& elementID, const String& text, Function<void (CommandResult&&)>&&);
</ins><span class="cx">     void executeScript(const String& script, RefPtr<JSON::Array>&& arguments, ExecuteScriptMode, Function<void (CommandResult&&)>&&);
</span><span class="cx">     void getAllCookies(Function<void (CommandResult&&)>&&);
</span><span class="cx">     void getNamedCookie(const String& name, Function<void (CommandResult&&)>&&);
</span><span class="lines">@@ -184,7 +184,7 @@
</span><span class="cx">         Alternate = 1 << 2,
</span><span class="cx">         Meta = 1 << 3,
</span><span class="cx">     };
</span><del>-    String virtualKeyForKeySequence(const String& keySequence, KeyModifier&);
</del><ins>+    String virtualKeyForKey(UChar, KeyModifier&);
</ins><span class="cx">     void performKeyboardInteractions(Vector<KeyboardInteraction>&&, Function<void (CommandResult&&)>&&);
</span><span class="cx"> 
</span><span class="cx">     struct InputSourceState {
</span></span></pre></div>
<a id="trunkSourceWebDriverWebDriverServicecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebDriver/WebDriverService.cpp (234835 => 234836)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1393,32 +1393,13 @@
</span><span class="cx">     if (!elementID)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    RefPtr<JSON::Array> valueArray;
-    if (!parameters->getArray("value"_s, valueArray)) {
</del><ins>+    String text;
+    if (!parameters->getString("text"_s, text) || text.isEmpty()) {
</ins><span class="cx">         completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    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));
</del><ins>+    m_session->elementSendKeys(elementID.value(), text, WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static bool findScriptAndArgumentsOrCompleteWithError(JSON::Object& parameters, Function<void (CommandResult&&)>& completionHandler, String& script, RefPtr<JSON::Array>& arguments)
</span></span></pre></div>
<a id="trunkWebDriverTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebDriverTests/ChangeLog (234835 => 234836)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebDriverTests/ChangeLog   2018-08-14 05:55:10 UTC (rev 234835)
+++ trunk/WebDriverTests/ChangeLog      2018-08-14 06:49:25 UTC (rev 234836)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2018-08-13  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        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:
+
</ins><span class="cx"> 2018-08-12  Michael Catanzaro  <mcatanzaro@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed GTK test gardening
</span></span></pre></div>
<a id="trunkWebDriverTestsTestExpectationsjson"></a>
<div class="modfile"><h4>Modified: trunk/WebDriverTests/TestExpectations.json (234835 => 234836)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -585,12 +585,6 @@
</span><span class="cx">     "imported/w3c/webdriver/tests/element_send_keys/form_controls.py": {
</span><span class="cx">         "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/182331"}}
</span><span class="cx">     },
</span><del>-    "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"}}
-    },
</del><span class="cx">     "imported/w3c/webdriver/tests/execute_script/collections.py": {
</span><span class="cx">         "subtests": {
</span><span class="cx">             "test_arguments": {
</span></span></pre>
</div>
</div>

</body>
</html>