Changeset 252180 in webkit


Ignore:
Timestamp:
Nov 7, 2019 4:09:12 AM (4 years ago)
Author:
Carlos Garcia Campos
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.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebDriver/ChangeLog

    r248846 r252180  
     12019-11-07  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: correctly handle errors when focusing element before sending key events
     4        https://bugs.webkit.org/show_bug.cgi?id=203945
     5
     6        Reviewed by Carlos Alberto Lopez Perez.
     7
     8        We are throwing an exception that is not correctly handled.
     9
     10        Fixes: imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_not_a_focusable_element
     11               imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_display_none
     12               imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_visibility_hidden
     13               imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_hidden
     14               imported/w3c/webdriver/tests/element_send_keys/interactability.py::test_disabled
     15
     16        * Session.cpp:
     17        (WebDriver::Session::elementSendKeys): Raise ElementNotInteractable error when element is not focusable.
     18
    1192019-08-18  Yusuke Suzuki  <ysuzuki@apple.com>
    220
  • trunk/Source/WebDriver/Session.cpp

    r245567 r252180  
    17571757            "    element.focus();"
    17581758            "    let tagName = element.tagName.toUpperCase();"
     1759            "    if (tagName === 'BODY' || element === document.documentElement)"
     1760            "        return;"
    17591761            "    let isTextElement = tagName === 'TEXTAREA' || (tagName === 'INPUT' && element.type === 'text');"
    17601762            "    if (isTextElement && element.selectionEnd == 0)"
    17611763            "        element.setSelectionRange(element.value.length, element.value.length);"
    17621764            "    if (element != doc.activeElement)"
    1763             "        throw new Error('cannot focus element');"
     1765            "        throw {name: 'ElementNotInteractable', message: 'Element is not focusable.'};"
    17641766            "}";
    17651767
  • trunk/Source/WebKit/ChangeLog

    r252175 r252180  
     12019-11-07  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: correctly handle errors when focusing element before sending key events
     4        https://bugs.webkit.org/show_bug.cgi?id=203945
     5
     6        Reviewed by Carlos Alberto Lopez Perez.
     7
     8        Handle ElementNotInteractable JavaScript exception to generate the appropriate Automation error.
     9
     10        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
     11        (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction):
     12
    1132019-11-06  Eric Liang  <ericliang@apple.com>
    214
  • trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp

    r248713 r252180  
    292292        else if (exceptionName == "InvalidSelector")
    293293            errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidSelector);
     294        else if (exceptionName == "ElementNotInteractable")
     295            errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::ElementNotInteractable);
    294296
    295297        JSValueRef messageValue = JSObjectGetProperty(context, const_cast<JSObjectRef>(exception), OpaqueJSString::tryCreate("message"_s).get(), nullptr);
  • trunk/WebDriverTests/ChangeLog

    r239824 r252180  
     12019-11-07  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: correctly handle errors when focusing element before sending key events
     4        https://bugs.webkit.org/show_bug.cgi?id=203945
     5
     6        Reviewed by Carlos Alberto Lopez Perez.
     7
     8        Remove expectations for tests that are now passing.
     9
     10        * TestExpectations.json:
     11
    1122019-01-10  Carlos Garcia Campos  <cgarcia@igalia.com>
    213
  • trunk/WebDriverTests/TestExpectations.json

    r239824 r252180  
    543543        "subtests": {
    544544            "test_document_element_is_interactable": {
    545                 "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/188545"}}
    546             },
    547             "test_not_a_focusable_element": {
    548                 "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/188545"}}
    549             },
    550             "test_not_displayed_element": {
    551                 "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/188545"}}
    552             },
    553             "test_hidden_element": {
    554                 "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/188545"}}
    555             },
    556             "test_disabled_element": {
    557545                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/188545"}}
    558546            }
Note: See TracChangeset for help on using the changeset viewer.