[GTK] WebDriver: tests in imported/w3c/webdriver/tests/element_clear/user_prompts...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2018 17:44:39 +0000 (17:44 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2018 17:44:39 +0000 (17:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192927

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2018-12-20
Reviewed by Michael Catanzaro.

Source/WebDriver:

Handle user prompts in element clear command.

* Session.cpp:
(WebDriver::Session::elementClear):

Source/WebKit:

Give the focus back to the web view when a dialog is dismissed.

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseContainerRemove):

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

Source/WebDriver/ChangeLog
Source/WebDriver/Session.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp

index 0f81c16..9106ab7 100644 (file)
@@ -1,3 +1,15 @@
+2018-12-20  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] WebDriver: tests in imported/w3c/webdriver/tests/element_clear/user_prompts.py are failing
+        https://bugs.webkit.org/show_bug.cgi?id=192927
+
+        Reviewed by Michael Catanzaro.
+
+        Handle user prompts in element clear command.
+
+        * Session.cpp:
+        (WebDriver::Session::elementClear):
+
 2018-12-19  Chris Dumez  <cdumez@apple.com>
 
         wtf/Optional.h: move-constructor and move-assignment operator should disengage the value being moved from
index 0c63a20..af2bb7a 100644 (file)
@@ -1560,21 +1560,28 @@ void Session::elementClear(const String& elementID, Function<void (CommandResult
         return;
     }
 
-    RefPtr<JSON::Array> arguments = JSON::Array::create();
-    arguments->pushString(createElement(elementID)->toJSONString());
-
-    RefPtr<JSON::Object> parameters = JSON::Object::create();
-    parameters->setString("browsingContextHandle"_s, m_toplevelBrowsingContext.value());
-    if (m_currentBrowsingContext)
-        parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
-    parameters->setString("function"_s, FormElementClearJavaScript);
-    parameters->setArray("arguments"_s, WTFMove(arguments));
-    m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
-        if (response.isError) {
-            completionHandler(CommandResult::fail(WTFMove(response.responseObject)));
+    handleUserPrompts([this, elementID, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
+        if (result.isError()) {
+            completionHandler(WTFMove(result));
             return;
         }
-        completionHandler(CommandResult::success());
+
+        RefPtr<JSON::Array> arguments = JSON::Array::create();
+        arguments->pushString(createElement(elementID)->toJSONString());
+
+        RefPtr<JSON::Object> parameters = JSON::Object::create();
+        parameters->setString("browsingContextHandle"_s, m_toplevelBrowsingContext.value());
+        if (m_currentBrowsingContext)
+            parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
+        parameters->setString("function"_s, FormElementClearJavaScript);
+        parameters->setArray("arguments"_s, WTFMove(arguments));
+        m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
+            if (response.isError) {
+                completionHandler(CommandResult::fail(WTFMove(response.responseObject)));
+                return;
+            }
+            completionHandler(CommandResult::success());
+        });
     });
 }
 
index d674b15..c814205 100644 (file)
@@ -1,3 +1,15 @@
+2018-12-20  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] WebDriver: tests in imported/w3c/webdriver/tests/element_clear/user_prompts.py are failing
+        https://bugs.webkit.org/show_bug.cgi?id=192927
+
+        Reviewed by Michael Catanzaro.
+
+        Give the focus back to the web view when a dialog is dismissed.
+
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseContainerRemove):
+
 2018-12-20  Tim Horton  <timothy_horton@apple.com>
 
         Unparented WKWebView can't retrieve main resource data for a main frame plugin
index d7d0a6d..4b26b10 100644 (file)
@@ -460,6 +460,8 @@ static void webkitWebViewBaseContainerRemove(GtkContainer* container, GtkWidget*
         priv->inspectorViewSize = 0;
     } else if (priv->dialog == widget) {
         priv->dialog = nullptr;
+        if (gtk_widget_get_visible(widgetContainer))
+            gtk_widget_grab_focus(widgetContainer);
     } else {
         ASSERT(priv->children.contains(widget));
         priv->children.remove(widget);