Title: [226058] releases/WebKitGTK/webkit-2.18/Source/WebDriver
Revision
226058
Author
carlo...@webkit.org
Date
2017-12-18 09:42:53 -0800 (Mon, 18 Dec 2017)

Log Message

Merge r225970 - WebDriver: add support for accept/dismiss and notify unhandled prompt behavior
https://bugs.webkit.org/show_bug.cgi?id=179999

Reviewed by Carlos Alberto Lopez Perez.

They work as accept and dismiss, but unexpected alert open is still reported.

18. User Prompts
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-known-prompt-handling-approaches-table

* Capabilities.h: Add DismissAndNotify and AcceptAndNotify to UnhandledPromptBehavior enum.
* Session.cpp:
(WebDriver::Session::handleUnexpectedAlertOpen): Move default implementation to dismissAndNotifyAlert and
acceptAndNotifyAlert and use dismissAndNotifyAlert by default.
(WebDriver::Session::dismissAndNotifyAlert):
(WebDriver::Session::acceptAndNotifyAlert):
* Session.h:
* WebDriverService.cpp:
(WebDriver::deserializeUnhandledPromptBehavior): Handle accept/dismiss and notify.
(WebDriver::WebDriverService::newSession): Ditto.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.18/Source/WebDriver/Capabilities.h (226057 => 226058)


--- releases/WebKitGTK/webkit-2.18/Source/WebDriver/Capabilities.h	2017-12-18 17:41:02 UTC (rev 226057)
+++ releases/WebKitGTK/webkit-2.18/Source/WebDriver/Capabilities.h	2017-12-18 17:42:53 UTC (rev 226058)
@@ -47,6 +47,8 @@
 enum class UnhandledPromptBehavior {
     Dismiss,
     Accept,
+    DismissAndNotify,
+    AcceptAndNotify,
     Ignore
 };
 

Modified: releases/WebKitGTK/webkit-2.18/Source/WebDriver/ChangeLog (226057 => 226058)


--- releases/WebKitGTK/webkit-2.18/Source/WebDriver/ChangeLog	2017-12-18 17:41:02 UTC (rev 226057)
+++ releases/WebKitGTK/webkit-2.18/Source/WebDriver/ChangeLog	2017-12-18 17:42:53 UTC (rev 226058)
@@ -1,3 +1,26 @@
+2017-12-15  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        WebDriver: add support for accept/dismiss and notify unhandled prompt behavior
+        https://bugs.webkit.org/show_bug.cgi?id=179999
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        They work as accept and dismiss, but unexpected alert open is still reported.
+
+        18. User Prompts
+        https://w3c.github.io/webdriver/webdriver-spec.html#dfn-known-prompt-handling-approaches-table
+
+        * Capabilities.h: Add DismissAndNotify and AcceptAndNotify to UnhandledPromptBehavior enum.
+        * Session.cpp:
+        (WebDriver::Session::handleUnexpectedAlertOpen): Move default implementation to dismissAndNotifyAlert and
+        acceptAndNotifyAlert and use dismissAndNotifyAlert by default.
+        (WebDriver::Session::dismissAndNotifyAlert):
+        (WebDriver::Session::acceptAndNotifyAlert):
+        * Session.h:
+        * WebDriverService.cpp:
+        (WebDriver::deserializeUnhandledPromptBehavior): Handle accept/dismiss and notify.
+        (WebDriver::WebDriverService::newSession): Ditto.
+
 2017-12-11  Carlos Garcia Campos  <cgar...@igalia.com>
 
         WebDriver: get active element should return no such element error when there isn't an active element

Modified: releases/WebKitGTK/webkit-2.18/Source/WebDriver/Session.cpp (226057 => 226058)


--- releases/WebKitGTK/webkit-2.18/Source/WebDriver/Session.cpp	2017-12-18 17:41:02 UTC (rev 226057)
+++ releases/WebKitGTK/webkit-2.18/Source/WebDriver/Session.cpp	2017-12-18 17:42:53 UTC (rev 226058)
@@ -190,20 +190,7 @@
 
 void Session::handleUnexpectedAlertOpen(Function<void (CommandResult&&)>&& completionHandler)
 {
-    if (!capabilities().unhandledPromptBehavior) {
-        reportUnexpectedAlertOpen([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
-            dismissAlert([this, errorResult = WTFMove(result), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
-                if (result.isError()) {
-                    completionHandler(WTFMove(result));
-                    return;
-                }
-                completionHandler(WTFMove(errorResult));
-            });
-        });
-        return;
-    }
-
-    switch (capabilities().unhandledPromptBehavior.value()) {
+    switch (capabilities().unhandledPromptBehavior.value_or(UnhandledPromptBehavior::DismissAndNotify)) {
     case UnhandledPromptBehavior::Dismiss:
         dismissAlert(WTFMove(completionHandler));
         break;
@@ -210,6 +197,12 @@
     case UnhandledPromptBehavior::Accept:
         acceptAlert(WTFMove(completionHandler));
         break;
+    case UnhandledPromptBehavior::DismissAndNotify:
+        dismissAndNotifyAlert(WTFMove(completionHandler));
+        break;
+    case UnhandledPromptBehavior::AcceptAndNotify:
+        acceptAndNotifyAlert(WTFMove(completionHandler));
+        break;
     case UnhandledPromptBehavior::Ignore:
         reportUnexpectedAlertOpen(WTFMove(completionHandler));
         break;
@@ -216,6 +209,32 @@
     }
 }
 
+void Session::dismissAndNotifyAlert(Function<void (CommandResult&&)>&& completionHandler)
+{
+    reportUnexpectedAlertOpen([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
+        dismissAlert([this, errorResult = WTFMove(result), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
+            if (result.isError()) {
+                completionHandler(WTFMove(result));
+                return;
+            }
+            completionHandler(WTFMove(errorResult));
+        });
+    });
+}
+
+void Session::acceptAndNotifyAlert(Function<void (CommandResult&&)>&& completionHandler)
+{
+    reportUnexpectedAlertOpen([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
+        acceptAlert([this, errorResult = WTFMove(result), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
+            if (result.isError()) {
+                completionHandler(WTFMove(result));
+                return;
+            }
+            completionHandler(WTFMove(errorResult));
+        });
+    });
+}
+
 void Session::reportUnexpectedAlertOpen(Function<void (CommandResult&&)>&& completionHandler)
 {
     getAlertText([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) {

Modified: releases/WebKitGTK/webkit-2.18/Source/WebDriver/Session.h (226057 => 226058)


--- releases/WebKitGTK/webkit-2.18/Source/WebDriver/Session.h	2017-12-18 17:41:02 UTC (rev 226057)
+++ releases/WebKitGTK/webkit-2.18/Source/WebDriver/Session.h	2017-12-18 17:42:53 UTC (rev 226058)
@@ -125,6 +125,8 @@
 
     void handleUserPrompts(Function<void (CommandResult&&)>&&);
     void handleUnexpectedAlertOpen(Function<void (CommandResult&&)>&&);
+    void dismissAndNotifyAlert(Function<void (CommandResult&&)>&&);
+    void acceptAndNotifyAlert(Function<void (CommandResult&&)>&&);
     void reportUnexpectedAlertOpen(Function<void (CommandResult&&)>&&);
 
     RefPtr<JSON::Object> createElement(RefPtr<JSON::Value>&&);

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


--- releases/WebKitGTK/webkit-2.18/Source/WebDriver/WebDriverService.cpp	2017-12-18 17:41:02 UTC (rev 226057)
+++ releases/WebKitGTK/webkit-2.18/Source/WebDriver/WebDriverService.cpp	2017-12-18 17:42:53 UTC (rev 226058)
@@ -313,6 +313,10 @@
         return UnhandledPromptBehavior::Dismiss;
     if (unhandledPromptBehavior == "accept")
         return UnhandledPromptBehavior::Accept;
+    if (unhandledPromptBehavior == "dismiss and notify")
+        return UnhandledPromptBehavior::DismissAndNotify;
+    if (unhandledPromptBehavior == "accept and notify")
+        return UnhandledPromptBehavior::AcceptAndNotify;
     if (unhandledPromptBehavior == "ignore")
         return UnhandledPromptBehavior::Ignore;
     return std::nullopt;
@@ -651,6 +655,12 @@
                 case UnhandledPromptBehavior::Accept:
                     capabilitiesObject->setString(ASCIILiteral("unhandledPromptBehavior"), "accept");
                     break;
+                case UnhandledPromptBehavior::DismissAndNotify:
+                    capabilitiesObject->setString(ASCIILiteral("unhandledPromptBehavior"), "dismiss and notify");
+                    break;
+                case UnhandledPromptBehavior::AcceptAndNotify:
+                    capabilitiesObject->setString(ASCIILiteral("unhandledPromptBehavior"), "accept and notify");
+                    break;
                 case UnhandledPromptBehavior::Ignore:
                     capabilitiesObject->setString(ASCIILiteral("unhandledPromptBehavior"), "ignore");
                     break;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to