Title: [239610] trunk/Source/WebDriver
Revision
239610
Author
[email protected]
Date
2019-01-04 08:27:24 -0800 (Fri, 04 Jan 2019)

Log Message

WebDriver: element click command should handle user prompts
https://bugs.webkit.org/show_bug.cgi?id=193139

Reviewed by Michael Catanzaro.

* Session.cpp:
(WebDriver::Session::elementClick): Handle user prompts.

Modified Paths

Diff

Modified: trunk/Source/WebDriver/ChangeLog (239609 => 239610)


--- trunk/Source/WebDriver/ChangeLog	2019-01-04 15:32:01 UTC (rev 239609)
+++ trunk/Source/WebDriver/ChangeLog	2019-01-04 16:27:24 UTC (rev 239610)
@@ -1,5 +1,15 @@
 2019-01-04  Carlos Garcia Campos  <[email protected]>
 
+        WebDriver: element click command should handle user prompts
+        https://bugs.webkit.org/show_bug.cgi?id=193139
+
+        Reviewed by Michael Catanzaro.
+
+        * Session.cpp:
+        (WebDriver::Session::elementClick): Handle user prompts.
+
+2019-01-04  Carlos Garcia Campos  <[email protected]>
+
         [GLIB] WebDriver: browser close not correctly detected on session close in some cases
         https://bugs.webkit.org/show_bug.cgi?id=193104
 

Modified: trunk/Source/WebDriver/Session.cpp (239609 => 239610)


--- trunk/Source/WebDriver/Session.cpp	2019-01-04 15:32:01 UTC (rev 239609)
+++ trunk/Source/WebDriver/Session.cpp	2019-01-04 16:27:24 UTC (rev 239610)
@@ -1520,41 +1520,47 @@
         return;
     }
 
-    OptionSet<ElementLayoutOption> options = { ElementLayoutOption::ScrollIntoViewIfNeeded, ElementLayoutOption::UseViewportCoordinates };
-    computeElementLayout(elementID, options, [this, protectedThis = makeRef(*this), elementID, completionHandler = WTFMove(completionHandler)](Optional<Rect>&& rect, Optional<Point>&& inViewCenter, bool isObscured, RefPtr<JSON::Object>&& error) mutable {
-        if (!rect || error) {
-            completionHandler(CommandResult::fail(WTFMove(error)));
+    handleUserPrompts([this, elementID, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
+        if (result.isError()) {
+            completionHandler(WTFMove(result));
             return;
         }
-        if (isObscured) {
-            completionHandler(CommandResult::fail(CommandResult::ErrorCode::ElementClickIntercepted));
-            return;
-        }
-        if (!inViewCenter) {
-            completionHandler(CommandResult::fail(CommandResult::ErrorCode::ElementNotInteractable));
-            return;
-        }
-
-        getElementTagName(elementID, [this, elementID, inViewCenter = WTFMove(inViewCenter), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
-            bool isOptionElement = false;
-            if (!result.isError()) {
-                String tagName;
-                if (result.result()->asString(tagName))
-                    isOptionElement = tagName == "option";
+        OptionSet<ElementLayoutOption> options = { ElementLayoutOption::ScrollIntoViewIfNeeded, ElementLayoutOption::UseViewportCoordinates };
+        computeElementLayout(elementID, options, [this, protectedThis = makeRef(*this), elementID, completionHandler = WTFMove(completionHandler)](Optional<Rect>&& rect, Optional<Point>&& inViewCenter, bool isObscured, RefPtr<JSON::Object>&& error) mutable {
+            if (!rect || error) {
+                completionHandler(CommandResult::fail(WTFMove(error)));
+                return;
             }
+            if (isObscured) {
+                completionHandler(CommandResult::fail(CommandResult::ErrorCode::ElementClickIntercepted));
+                return;
+            }
+            if (!inViewCenter) {
+                completionHandler(CommandResult::fail(CommandResult::ErrorCode::ElementNotInteractable));
+                return;
+            }
 
-            Function<void (CommandResult&&)> continueAfterClickFunction = [this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
-                if (result.isError()) {
-                    completionHandler(WTFMove(result));
-                    return;
+            getElementTagName(elementID, [this, elementID, inViewCenter = WTFMove(inViewCenter), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
+                bool isOptionElement = false;
+                if (!result.isError()) {
+                    String tagName;
+                    if (result.result()->asString(tagName))
+                        isOptionElement = tagName == "option";
                 }
 
-                waitForNavigationToComplete(WTFMove(completionHandler));
-            };
-            if (isOptionElement)
-                selectOptionElement(elementID, WTFMove(continueAfterClickFunction));
-            else
-                performMouseInteraction(inViewCenter.value().x, inViewCenter.value().y, MouseButton::Left, MouseInteraction::SingleClick, WTFMove(continueAfterClickFunction));
+                Function<void (CommandResult&&)> continueAfterClickFunction = [this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
+                    if (result.isError()) {
+                        completionHandler(WTFMove(result));
+                        return;
+                    }
+
+                    waitForNavigationToComplete(WTFMove(completionHandler));
+                };
+                if (isOptionElement)
+                    selectOptionElement(elementID, WTFMove(continueAfterClickFunction));
+                else
+                    performMouseInteraction(inViewCenter.value().x, inViewCenter.value().y, MouseButton::Left, MouseInteraction::SingleClick, WTFMove(continueAfterClickFunction));
+            });
         });
     });
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to