Title: [219554] trunk/Source/WebKit
Revision
219554
Author
carlo...@webkit.org
Date
2017-07-17 00:01:07 -0700 (Mon, 17 Jul 2017)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (219553 => 219554)


--- trunk/Source/WebKit/ChangeLog	2017-07-17 06:58:48 UTC (rev 219553)
+++ trunk/Source/WebKit/ChangeLog	2017-07-17 07:01:07 UTC (rev 219554)
@@ -1,3 +1,22 @@
+2017-07-16  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        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.
+
 2017-07-16  Brady Eidson  <beid...@apple.com>
 
         Crash when a WKHTTPCookieStore outlives its owning WKWebsiteDataStore.

Modified: trunk/Source/WebKit/UIProcess/Automation/atoms/FindNodes.js (219553 => 219554)


--- trunk/Source/WebKit/UIProcess/Automation/atoms/FindNodes.js	2017-07-17 06:58:48 UTC (rev 219553)
+++ trunk/Source/WebKit/UIProcess/Automation/atoms/FindNodes.js	2017-07-17 07:01:07 UTC (rev 219554)
@@ -52,9 +52,10 @@
     case "xpath":
         break;
     default:
-        // Unknown strategy.
-        callback(firstResultOnly ? null : []);
-        return;
+        // §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
+        throw { name: "InvalidParameter", message: ("Unsupported locator strategy: " + strategy + ".") };
     }
 
     function escape(string) {

Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp (219553 => 219554)


--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2017-07-17 06:58:48 UTC (rev 219553)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2017-07-17 07:01:07 UTC (rev 219554)
@@ -273,7 +273,9 @@
         if (exceptionName->string() == "NodeNotFound")
             errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::NodeNotFound);
         else if (exceptionName->string() == "InvalidElementState")
-            errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidElementState);        
+            errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidElementState);
+        else if (exceptionName->string() == "InvalidParameter")
+            errorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::InvalidParameter);
 
         JSValueRef messageValue = JSObjectGetProperty(context, const_cast<JSObjectRef>(exception), toJSString(ASCIILiteral("message")).get(), nullptr);
         exceptionMessage.adopt(JSValueToStringCopy(context, messageValue, nullptr));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to