Changeset 219554 in webkit


Ignore:
Timestamp:
Jul 17, 2017 12:01:07 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

Web Automation: FindNodes should throw an error in case of invalid strategy
https://bugs.webkit.org/show_bug.cgi?id=174497

Reviewed by Brian Burg.

We are currently returning null or empty list. According to the spec in 12.2 Find Element and 12.3 Find
Elements, step 4: "If location strategy is not present as a keyword in the table of location strategies, return
error with error code invalid argument.".
https://www.w3.org/TR/webdriver/#find-element.

This is causing test test_should_throw_an_error_if_user_passes_in_invalid_by_when_find_elements to fail.

  • UIProcess/Automation/atoms/FindNodes.js:

(switch): Throw an error in case of unknown strategy.

  • WebProcess/Automation/WebAutomationSessionProxy.cpp:

(WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Handle InvalidParameter exceptions.

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r219550 r219554  
     12017-07-16  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Web Automation: FindNodes should throw an error in case of invalid strategy
     4        https://bugs.webkit.org/show_bug.cgi?id=174497
     5
     6        Reviewed by Brian Burg.
     7
     8        We are currently returning null or empty list. According to the spec in 12.2 Find Element and 12.3 Find
     9        Elements, step 4: "If location strategy is not present as a keyword in the table of location strategies, return
     10        error with error code invalid argument.".
     11        https://www.w3.org/TR/webdriver/#find-element.
     12
     13        This is causing test test_should_throw_an_error_if_user_passes_in_invalid_by_when_find_elements to fail.
     14
     15        * UIProcess/Automation/atoms/FindNodes.js:
     16        (switch): Throw an error in case of unknown strategy.
     17        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
     18        (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction): Handle InvalidParameter exceptions.
     19
    1202017-07-16  Brady Eidson  <beidson@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/Automation/atoms/FindNodes.js

    r219388 r219554  
    5353        break;
    5454    default:
    55         // Unknown strategy.
    56         callback(firstResultOnly ? null : []);
    57         return;
     55        // §12.2 Find Element and §12.3 Find Elements, step 4: If location strategy is not present as a keyword
     56        // in the table of location strategies, return error with error code invalid argument.
     57        // https://www.w3.org/TR/webdriver/#find-element
     58        throw { name: "InvalidParameter", message: ("Unsupported locator strategy: " + strategy + ".") };
    5859    }
    5960
  • trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp

    r217041 r219554  
    274274            errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::NodeNotFound);
    275275        else if (exceptionName->string() == "InvalidElementState")
    276             errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidElementState);       
     276            errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidElementState);
     277        else if (exceptionName->string() == "InvalidParameter")
     278            errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidParameter);
    277279
    278280        JSValueRef messageValue = JSObjectGetProperty(context, const_cast<JSObjectRef>(exception), toJSString(ASCIILiteral("message")).get(), nullptr);
Note: See TracChangeset for help on using the changeset viewer.