Title: [226043] releases/WebKitGTK/webkit-2.18/Source/WebDriver
Revision
226043
Author
[email protected]
Date
2017-12-18 08:56:18 -0800 (Mon, 18 Dec 2017)

Log Message

Merge r225326 - WebDriver: locator strategy should be validated before trying to find elements
https://bugs.webkit.org/show_bug.cgi?id=180187

Reviewed by Carlos Alberto Lopez Perez.

We currently rely on the js atom to raise an exception in case the locator strategy is not valid, but in case of
find element from element, if the element doesn't exist we fail with stale element error instead of invalid
argument as expected. So, let's validate the strategies when parsing them, which would also avoid going to the
browser in cae of invalid strategy.

Fixes: imported/w3c/webdriver/tests/retrieval/find_element_from_element.py::test_invalid_using_argument[a]

* WebDriverService.cpp:
(WebDriver::isValidStrategy):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.18/Source/WebDriver/ChangeLog (226042 => 226043)


--- releases/WebKitGTK/webkit-2.18/Source/WebDriver/ChangeLog	2017-12-18 16:56:13 UTC (rev 226042)
+++ releases/WebKitGTK/webkit-2.18/Source/WebDriver/ChangeLog	2017-12-18 16:56:18 UTC (rev 226043)
@@ -1,5 +1,23 @@
 2017-11-30  Carlos Garcia Campos  <[email protected]>
 
+        WebDriver: locator strategy should be validated before trying to find elements
+        https://bugs.webkit.org/show_bug.cgi?id=180187
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        We currently rely on the js atom to raise an exception in case the locator strategy is not valid, but in case of
+        find element from element, if the element doesn't exist we fail with stale element error instead of invalid
+        argument as expected. So, let's validate the strategies when parsing them, which would also avoid going to the
+        browser in cae of invalid strategy.
+
+        Fixes: imported/w3c/webdriver/tests/retrieval/find_element_from_element.py::test_invalid_using_argument[a]
+
+        * WebDriverService.cpp:
+        (WebDriver::isValidStrategy):
+        (WebDriver::findStrategyAndSelectorOrCompleteWithError):
+
+2017-11-30  Carlos Garcia Campos  <[email protected]>
+
         WebDriver: remove elementSubmit command
         https://bugs.webkit.org/show_bug.cgi?id=180186
 

Modified: releases/WebKitGTK/webkit-2.18/Source/WebDriver/WebDriverService.cpp (226042 => 226043)


--- releases/WebKitGTK/webkit-2.18/Source/WebDriver/WebDriverService.cpp	2017-12-18 16:56:13 UTC (rev 226042)
+++ releases/WebKitGTK/webkit-2.18/Source/WebDriver/WebDriverService.cpp	2017-12-18 16:56:18 UTC (rev 226043)
@@ -984,9 +984,20 @@
     return elementID;
 }
 
+static inline bool isValidStrategy(const String& strategy)
+{
+    // ยง12.1 Locator Strategies.
+    // https://w3c.github.io/webdriver/webdriver-spec.html#dfn-table-of-location-strategies
+    return strategy == "css selector"
+        || strategy == "link text"
+        || strategy == "partial link text"
+        || strategy == "tag name"
+        || strategy == "xpath";
+}
+
 static bool findStrategyAndSelectorOrCompleteWithError(JSON::Object& parameters, Function<void (CommandResult&&)>& completionHandler, String& strategy, String& selector)
 {
-    if (!parameters.getString(ASCIILiteral("using"), strategy)) {
+    if (!parameters.getString(ASCIILiteral("using"), strategy) || !isValidStrategy(strategy)) {
         completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
         return false;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to