WebDriver: include all capabilities in the new session response
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Aug 2018 06:51:44 +0000 (06:51 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Aug 2018 06:51:44 +0000 (06:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188511

Reviewed by Brian Burg.

As expected by the tests, using the default values when the capability is not provided by the user.

* WebDriverService.cpp:
(WebDriver::WebDriverService::createSession):

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

Source/WebDriver/ChangeLog
Source/WebDriver/WebDriverService.cpp

index cc80ff2..47f4e53 100644 (file)
@@ -1,5 +1,17 @@
 2018-08-13  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        WebDriver: include all capabilities in the new session response
+        https://bugs.webkit.org/show_bug.cgi?id=188511
+
+        Reviewed by Brian Burg.
+
+        As expected by the tests, using the default values when the capability is not provided by the user.
+
+        * WebDriverService.cpp:
+        (WebDriver::WebDriverService::createSession):
+
+2018-08-13  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         WebDriver: several element_send_keys tests are failing since added
         https://bugs.webkit.org/show_bug.cgi?id=181644
 
index 076ca00..dab0fa8 100644 (file)
@@ -695,34 +695,27 @@ void WebDriverService::createSession(Vector<Capabilities>&& capabilitiesList, st
             resultObject->setString("sessionId"_s, m_session->id());
             RefPtr<JSON::Object> capabilitiesObject = JSON::Object::create();
             const auto& capabilities = m_session->capabilities();
-            if (capabilities.browserName)
-                capabilitiesObject->setString("browserName"_s, capabilities.browserName.value());
-            if (capabilities.browserVersion)
-                capabilitiesObject->setString("browserVersion"_s, capabilities.browserVersion.value());
-            if (capabilities.platformName)
-                capabilitiesObject->setString("platformName"_s, capabilities.platformName.value());
-            if (capabilities.acceptInsecureCerts)
-                capabilitiesObject->setBoolean("acceptInsecureCerts"_s, capabilities.acceptInsecureCerts.value());
-            if (capabilities.setWindowRect)
-                capabilitiesObject->setBoolean("setWindowRect"_s, capabilities.setWindowRect.value());
-            if (capabilities.unhandledPromptBehavior) {
-                switch (capabilities.unhandledPromptBehavior.value()) {
-                case UnhandledPromptBehavior::Dismiss:
-                    capabilitiesObject->setString("unhandledPromptBehavior"_s, "dismiss");
-                    break;
-                case UnhandledPromptBehavior::Accept:
-                    capabilitiesObject->setString("unhandledPromptBehavior"_s, "accept");
-                    break;
-                case UnhandledPromptBehavior::DismissAndNotify:
-                    capabilitiesObject->setString("unhandledPromptBehavior"_s, "dismiss and notify");
-                    break;
-                case UnhandledPromptBehavior::AcceptAndNotify:
-                    capabilitiesObject->setString("unhandledPromptBehavior"_s, "accept and notify");
-                    break;
-                case UnhandledPromptBehavior::Ignore:
-                    capabilitiesObject->setString("unhandledPromptBehavior"_s, "ignore");
-                    break;
-                }
+            capabilitiesObject->setString("browserName"_s, capabilities.browserName.value_or(emptyString()));
+            capabilitiesObject->setString("browserVersion"_s, capabilities.browserVersion.value_or(emptyString()));
+            capabilitiesObject->setString("platformName"_s, capabilities.platformName.value_or(emptyString()));
+            capabilitiesObject->setBoolean("acceptInsecureCerts"_s, capabilities.acceptInsecureCerts.value_or(false));
+            capabilitiesObject->setBoolean("setWindowRect"_s, capabilities.setWindowRect.value_or(true));
+            switch (capabilities.unhandledPromptBehavior.value_or(UnhandledPromptBehavior::DismissAndNotify)) {
+            case UnhandledPromptBehavior::Dismiss:
+                capabilitiesObject->setString("unhandledPromptBehavior"_s, "dismiss");
+                break;
+            case UnhandledPromptBehavior::Accept:
+                capabilitiesObject->setString("unhandledPromptBehavior"_s, "accept");
+                break;
+            case UnhandledPromptBehavior::DismissAndNotify:
+                capabilitiesObject->setString("unhandledPromptBehavior"_s, "dismiss and notify");
+                break;
+            case UnhandledPromptBehavior::AcceptAndNotify:
+                capabilitiesObject->setString("unhandledPromptBehavior"_s, "accept and notify");
+                break;
+            case UnhandledPromptBehavior::Ignore:
+                capabilitiesObject->setString("unhandledPromptBehavior"_s, "ignore");
+                break;
             }
             switch (capabilities.pageLoadStrategy.value_or(PageLoadStrategy::Normal)) {
             case PageLoadStrategy::None: