Title: [269421] trunk
Revision
269421
Author
[email protected]
Date
2020-11-05 00:47:42 -0800 (Thu, 05 Nov 2020)

Log Message

WebDriver: handle surrogate pairs in keyboard actions
https://bugs.webkit.org/show_bug.cgi?id=218279

Reviewed by Brian Burg.

Source/WebKit:

And fail with invalid argument if the string can be represented as a single code point.

Fixes: imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_codepoint_keys_behave_correctly[\U0001f604]
       imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_codepoint_keys_behave_correctly[\U0001f60d]
       imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_invalid_multiple_codepoint_keys_fail[fa]
       imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_invalid_multiple_codepoint_keys_fail[\u0ba8\u0bbfb]
       imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_invalid_multiple_codepoint_keys_fail[\u0ba8\u0bbf\u0ba8]
       imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_invalid_multiple_codepoint_keys_fail[\u1100\u1161\u11a8c]

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::pressedCharKey):
(WebKit::WebAutomationSession::performInteractionSequence):

WebDriverTests:

Remove expectations for tests that are now passing.

* TestExpectations.json:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (269420 => 269421)


--- trunk/Source/WebKit/ChangeLog	2020-11-05 08:46:57 UTC (rev 269420)
+++ trunk/Source/WebKit/ChangeLog	2020-11-05 08:47:42 UTC (rev 269421)
@@ -1,3 +1,23 @@
+2020-11-05  Carlos Garcia Campos  <[email protected]>
+
+        WebDriver: handle surrogate pairs in keyboard actions
+        https://bugs.webkit.org/show_bug.cgi?id=218279
+
+        Reviewed by Brian Burg.
+
+        And fail with invalid argument if the string can be represented as a single code point.
+
+        Fixes: imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_codepoint_keys_behave_correctly[\U0001f604]
+               imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_codepoint_keys_behave_correctly[\U0001f60d]
+               imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_invalid_multiple_codepoint_keys_fail[fa]
+               imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_invalid_multiple_codepoint_keys_fail[\u0ba8\u0bbfb]
+               imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_invalid_multiple_codepoint_keys_fail[\u0ba8\u0bbf\u0ba8]
+               imported/w3c/webdriver/tests/perform_actions/key_special_keys.py::test_invalid_multiple_codepoint_keys_fail[\u1100\u1161\u11a8c]
+
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::pressedCharKey):
+        (WebKit::WebAutomationSession::performInteractionSequence):
+
 2020-11-05  Jiewen Tan  <[email protected]>
 
         [WebAuthn] Determine an AAGUID for the platform authenticators

Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (269420 => 269421)


--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp	2020-11-05 08:46:57 UTC (rev 269420)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp	2020-11-05 08:47:42 UTC (rev 269421)
@@ -1944,6 +1944,22 @@
         return key;
     }
 }
+
+static Optional<UChar32> pressedCharKey(const String& pressedCharKeyString)
+{
+    switch (pressedCharKeyString.length()) {
+    case 1:
+        return pressedCharKeyString.characterAt(0);
+    case 2: {
+        auto lead = pressedCharKeyString.characterAt(0);
+        auto trail = pressedCharKeyString.characterAt(1);
+        if (U16_IS_LEAD(lead) && U16_IS_TRAIL(trail))
+            return U16_GET_SUPPLEMENTARY(lead, trail);
+    }
+    }
+
+    return WTF::nullopt;
+}
 #endif // ENABLE(WEBDRIVER_ACTIONS_API)
 
 void WebAutomationSession::performInteractionSequence(const Inspector::Protocol::Automation::BrowsingContextHandle& handle, const Inspector::Protocol::Automation::FrameHandle& frameHandle, Ref<JSON::Array>&& inputSources, Ref<JSON::Array>&& steps, Ref<WebAutomationSession::PerformInteractionSequenceCallback>&& callback)
@@ -2055,8 +2071,12 @@
             SimulatedInputSourceState sourceState { };
 
             auto pressedCharKeyString = stateObject->getString("pressedCharKey"_s);
-            if (!!pressedCharKeyString)
-                sourceState.pressedCharKeys.add(pressedCharKeyString.characterAt(0));
+            if (!!pressedCharKeyString) {
+                auto charKey = pressedCharKey(pressedCharKeyString);
+                if (!charKey)
+                    ASYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "Invalid 'pressedCharKey'.");
+                sourceState.pressedCharKeys.add(*charKey);
+            }
 
             if (auto pressedVirtualKeysArray = stateObject->getArray("pressedVirtualKeys"_s)) {
                 VirtualKeyMap pressedVirtualKeys;

Modified: trunk/WebDriverTests/ChangeLog (269420 => 269421)


--- trunk/WebDriverTests/ChangeLog	2020-11-05 08:46:57 UTC (rev 269420)
+++ trunk/WebDriverTests/ChangeLog	2020-11-05 08:47:42 UTC (rev 269421)
@@ -1,3 +1,14 @@
+2020-11-05  Carlos Garcia Campos  <[email protected]>
+
+        WebDriver: handle surrogate pairs in keyboard actions
+        https://bugs.webkit.org/show_bug.cgi?id=218279
+
+        Reviewed by Brian Burg.
+
+        Remove expectations for tests that are now passing.
+
+        * TestExpectations.json:
+
 2020-11-03  Lauro Moura  <[email protected]>
 
         [WebDriver] Update config.json after tools update in r269235

Modified: trunk/WebDriverTests/TestExpectations.json (269420 => 269421)


--- trunk/WebDriverTests/TestExpectations.json	2020-11-05 08:46:57 UTC (rev 269420)
+++ trunk/WebDriverTests/TestExpectations.json	2020-11-05 08:47:42 UTC (rev 269421)
@@ -447,7 +447,14 @@
         }
     },
     "imported/w3c/webdriver/tests/perform_actions/key_special_keys.py": {
-        "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/184967"}}
+        "subtests": {
+            "test_codepoint_keys_behave_correctly[\\u0ba8\\u0bbf]": {
+                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/184967"}}
+            },
+            "test_codepoint_keys_behave_correctly[\\u1100\\u1161\\u11a8]": {
+                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/184967"}}
+            }
+        }
     },
 
     "imported/w3c/webdriver/tests/close_window/close.py": {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to