WebDriver: several tests in imported/w3c/webdriver/tests/sessions/new_session/merge...
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jan 2018 16:22:55 +0000 (16:22 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Jan 2018 16:22:55 +0000 (16:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180407

Reviewed by Carlos Alberto Lopez Perez.

Source/WebDriver:

This is actually a bug in the spec, see https://github.com/w3c/webdriver/issues/1203. It seems the idea in any
case is that we should check all the firstMatch capabilities before matching them, and return if there's any
error.

* WebDriverService.cpp:
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):

WebDriverTests:

Remove expectations for tests that are passing now and update the bug number of the other ones referencing
#180407.

* TestExpectations.json:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227414 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebDriver/ChangeLog
Source/WebDriver/WebDriverService.cpp
WebDriverTests/ChangeLog
WebDriverTests/TestExpectations.json

index d4d4c5b..4823dce 100644 (file)
@@ -1,5 +1,20 @@
 2018-01-23  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        WebDriver: several tests in imported/w3c/webdriver/tests/sessions/new_session/merge.py are failing
+        https://bugs.webkit.org/show_bug.cgi?id=180407
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        This is actually a bug in the spec, see https://github.com/w3c/webdriver/issues/1203. It seems the idea in any
+        case is that we should check all the firstMatch capabilities before matching them, and return if there's any
+        error.
+
+        * WebDriverService.cpp:
+        (WebDriver::WebDriverService::mergeCapabilities const):
+        (WebDriver::WebDriverService::processCapabilities const):
+
+2018-01-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/response.py::test_timeouts fails
         https://bugs.webkit.org/show_bug.cgi?id=180412
 
index 04368ef..68ef921 100644 (file)
@@ -442,12 +442,8 @@ RefPtr<JSON::Object> WebDriverService::mergeCapabilities(const JSON::Object& req
         result->setValue(it->key, RefPtr<JSON::Value>(it->value));
 
     auto firstMatchEnd = firstMatchCapabilities.end();
-    for (auto it = firstMatchCapabilities.begin(); it != firstMatchEnd; ++it) {
-        if (requiredCapabilities.find(it->key) != requiredEnd)
-            return nullptr;
-
+    for (auto it = firstMatchCapabilities.begin(); it != firstMatchEnd; ++it)
         result->setValue(it->key, RefPtr<JSON::Value>(it->value));
-    }
 
     return result;
 }
@@ -575,6 +571,18 @@ RefPtr<JSON::Object> WebDriverService::processCapabilities(const JSON::Object& p
             completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument, String("Invalid firstMatch capabilities")));
             return nullptr;
         }
+
+        // Validate here that firstMatchCapabilities don't shadow alwaysMatchCapabilities.
+        auto requiredEnd = requiredCapabilities->end();
+        auto firstMatchEnd = firstMatchCapabilities->end();
+        for (auto it = firstMatchCapabilities->begin(); it != firstMatchEnd; ++it) {
+            if (requiredCapabilities->find(it->key) != requiredEnd) {
+                completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument,
+                    makeString("Invalid firstMatch capabilities: key ", it->key, " is present in alwaysMatch")));
+                return nullptr;
+            }
+        }
+
         // 5.2. Append validated capabilities to validated first match capabilities.
         validatedFirstMatchCapabilitiesList.uncheckedAppend(WTFMove(firstMatchCapabilities));
     }
index d19e15a..37c5ff0 100644 (file)
@@ -1,5 +1,17 @@
 2018-01-23  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        WebDriver: several tests in imported/w3c/webdriver/tests/sessions/new_session/merge.py are failing
+        https://bugs.webkit.org/show_bug.cgi?id=180407
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        Remove expectations for tests that are passing now and update the bug number of the other ones referencing
+        #180407.
+
+        * TestExpectations.json:
+
+2018-01-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/response.py::test_timeouts fails
         https://bugs.webkit.org/show_bug.cgi?id=180412
 
index 9036bb9..1bfa71c 100644 (file)
     },
     "imported/w3c/webdriver/tests/sessions/new_session/merge.py": {
         "subtests": {
-            "test_merge_invalid[unhandledPromptBehavior-value1]": {
-                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/180407"}}
-            },
-            "test_merge_invalid[unhandledPromptBehavior-value2]": {
-                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/180407"}}
-            },
             "test_merge_platformName": {
-                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/180407"}}
+                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/181984"}}
             },
             "test_merge_browserName": {
-                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/180407"}}
+                "expected": {"all": {"status": ["FAIL"], "bug": "webkit.org/b/181985"}}
             }
         }
     },