Title: [252180] trunk
Revision
252180
Author
[email protected]
Date
2019-11-07 04:09:12 -0800 (Thu, 07 Nov 2019)

Log Message

WebDriver: correctly handle errors when focusing element before sending key events
https://bugs.webkit.org/show_bug.cgi?id=203945

Reviewed by Carlos Alberto Lopez Perez.

Source/WebDriver:

We are throwing an exception that is not correctly handled.

Fixes: imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_not_a_focusable_element
       imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_display_none
       imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_visibility_hidden
       imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_hidden
       imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_disabled

* Session.cpp:
(WebDriver::Session::elementSendKeys): Raise ElementNotInteractable error when element is not focusable.

Source/WebKit:

Handle ElementNotInteractable _javascript_ exception to generate the appropriate Automation error.

* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction):

WebDriverTests:

Remove expectations for tests that are now passing.

* TestExpectations.json:

Modified Paths

Diff

Modified: trunk/Source/WebDriver/ChangeLog (252179 => 252180)


--- trunk/Source/WebDriver/ChangeLog	2019-11-07 09:52:27 UTC (rev 252179)
+++ trunk/Source/WebDriver/ChangeLog	2019-11-07 12:09:12 UTC (rev 252180)
@@ -1,3 +1,21 @@
+2019-11-07  Carlos Garcia Campos  <[email protected]>
+
+        WebDriver: correctly handle errors when focusing element before sending key events
+        https://bugs.webkit.org/show_bug.cgi?id=203945
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        We are throwing an exception that is not correctly handled.
+
+        Fixes: imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_not_a_focusable_element
+               imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_display_none
+               imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_visibility_hidden
+               imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_hidden
+               imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_disabled
+
+        * Session.cpp:
+        (WebDriver::Session::elementSendKeys): Raise ElementNotInteractable error when element is not focusable.
+
 2019-08-18  Yusuke Suzuki  <[email protected]>
 
         [WTF] Add makeUnique<T>, which ensures T is fast-allocated, makeUnique / makeUniqueWithoutFastMallocCheck part

Modified: trunk/Source/WebDriver/Session.cpp (252179 => 252180)


--- trunk/Source/WebDriver/Session.cpp	2019-11-07 09:52:27 UTC (rev 252179)
+++ trunk/Source/WebDriver/Session.cpp	2019-11-07 12:09:12 UTC (rev 252180)
@@ -1756,11 +1756,13 @@
             "        prevActiveElement.blur();"
             "    element.focus();"
             "    let tagName = element.tagName.toUpperCase();"
+            "    if (tagName === 'BODY' || element === document.documentElement)"
+            "        return;"
             "    let isTextElement = tagName === 'TEXTAREA' || (tagName === 'INPUT' && element.type === 'text');"
             "    if (isTextElement && element.selectionEnd == 0)"
             "        element.setSelectionRange(element.value.length, element.value.length);"
             "    if (element != doc.activeElement)"
-            "        throw new Error('cannot focus element');"
+            "        throw {name: 'ElementNotInteractable', message: 'Element is not focusable.'};"
             "}";
 
         RefPtr<JSON::Array> arguments = JSON::Array::create();

Modified: trunk/Source/WebKit/ChangeLog (252179 => 252180)


--- trunk/Source/WebKit/ChangeLog	2019-11-07 09:52:27 UTC (rev 252179)
+++ trunk/Source/WebKit/ChangeLog	2019-11-07 12:09:12 UTC (rev 252180)
@@ -1,3 +1,15 @@
+2019-11-07  Carlos Garcia Campos  <[email protected]>
+
+        WebDriver: correctly handle errors when focusing element before sending key events
+        https://bugs.webkit.org/show_bug.cgi?id=203945
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        Handle ElementNotInteractable _javascript_ exception to generate the appropriate Automation error.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction):
+
 2019-11-06  Eric Liang  <[email protected]>
 
         AX: WKWebView does not shift Accessibility Focus for Catalyst (203798)

Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp (252179 => 252180)


--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2019-11-07 09:52:27 UTC (rev 252179)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2019-11-07 12:09:12 UTC (rev 252180)
@@ -291,6 +291,8 @@
             errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidParameter);
         else if (exceptionName == "InvalidSelector")
             errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidSelector);
+        else if (exceptionName == "ElementNotInteractable")
+            errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::ElementNotInteractable);
 
         JSValueRef messageValue = JSObjectGetProperty(context, const_cast<JSObjectRef>(exception), OpaqueJSString::tryCreate("message"_s).get(), nullptr);
         exceptionMessage = adoptRef(JSValueToStringCopy(context, messageValue, nullptr))->string();

Modified: trunk/WebDriverTests/ChangeLog (252179 => 252180)


--- trunk/WebDriverTests/ChangeLog	2019-11-07 09:52:27 UTC (rev 252179)
+++ trunk/WebDriverTests/ChangeLog	2019-11-07 12:09:12 UTC (rev 252180)
@@ -1,3 +1,14 @@
+2019-11-07  Carlos Garcia Campos  <[email protected]>
+
+        WebDriver: correctly handle errors when focusing element before sending key events
+        https://bugs.webkit.org/show_bug.cgi?id=203945
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        Remove expectations for tests that are now passing.
+
+        * TestExpectations.json:
+
 2019-01-10  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed gardening. Mark user prompts tests in take screenshot commands as failure

Modified: trunk/WebDriverTests/TestExpectations.json (252179 => 252180)


--- trunk/WebDriverTests/TestExpectations.json	2019-11-07 09:52:27 UTC (rev 252179)
+++ trunk/WebDriverTests/TestExpectations.json	2019-11-07 12:09:12 UTC (rev 252180)
@@ -543,18 +543,6 @@
         "subtests": {
             "test_document_element_is_interactable": {
                 "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/188545"}}
-            },
-            "test_not_a_focusable_element": {
-                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/188545"}}
-            },
-            "test_not_displayed_element": {
-                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/188545"}}
-            },
-            "test_hidden_element": {
-                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/188545"}}
-            },
-            "test_disabled_element": {
-                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/188545"}}
             }
         }
     },
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to