[GTK] WebDriver: implement AutomationSessionClient::didDisconnectFromRemote
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 May 2018 15:24:58 +0000 (15:24 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 May 2018 15:24:58 +0000 (15:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185866

Reviewed by Brian Burg.

Source/WebDriver:

Close the dbus connection when receiving an empty target list.

* glib/SessionHostGlib.cpp:
(WebDriver::SessionHost::setTargetList):

Source/WebKit:

To handle the case of the session being closed by the browser, for example in case of a network process
crash. This is currently causing WebDriver tests to timeout in the bot.

* UIProcess/API/glib/WebKitAutomationSession.cpp: Add an implementation of didDisconnectFromRemote() to notify
the WebContext that the session will be closed.
* UIProcess/API/glib/WebKitWebContext.cpp: Remove the automation session when closed.
* UIProcess/API/glib/WebKitWebContextPrivate.h:

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

Source/WebDriver/ChangeLog
Source/WebDriver/glib/SessionHostGlib.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/glib/WebKitAutomationSession.cpp
Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp
Source/WebKit/UIProcess/API/glib/WebKitWebContextPrivate.h

index 2e10899..b2ff0df 100644 (file)
@@ -1,3 +1,15 @@
+2018-05-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] WebDriver: implement AutomationSessionClient::didDisconnectFromRemote
+        https://bugs.webkit.org/show_bug.cgi?id=185866
+
+        Reviewed by Brian Burg.
+
+        Close the dbus connection when receiving an empty target list.
+
+        * glib/SessionHostGlib.cpp:
+        (WebDriver::SessionHost::setTargetList):
+
 2018-05-21  Olivier Blin  <olivier.blin@softathome.com>
 
         [WPE][WebDriver] add ICU include dirs
index 12c9c1e..1807b84 100644 (file)
@@ -306,6 +306,8 @@ void SessionHost::setTargetList(uint64_t connectionID, Vector<Target>&& targetLi
     if (targetList.isEmpty()) {
         m_target = Target();
         m_connectionID = 0;
+        if (m_dbusConnection)
+            g_dbus_connection_close(m_dbusConnection.get(), nullptr, nullptr, nullptr);
         return;
     }
 
index 4f80874..d5837e3 100644 (file)
@@ -1,3 +1,18 @@
+2018-05-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] WebDriver: implement AutomationSessionClient::didDisconnectFromRemote
+        https://bugs.webkit.org/show_bug.cgi?id=185866
+
+        Reviewed by Brian Burg.
+
+        To handle the case of the session being closed by the browser, for example in case of a network process
+        crash. This is currently causing WebDriver tests to timeout in the bot.
+
+        * UIProcess/API/glib/WebKitAutomationSession.cpp: Add an implementation of didDisconnectFromRemote() to notify
+        the WebContext that the session will be closed.
+        * UIProcess/API/glib/WebKitWebContext.cpp: Remove the automation session when closed.
+        * UIProcess/API/glib/WebKitWebContextPrivate.h:
+
 2018-05-22  Brent Fulgham  <bfulgham@apple.com>
 
         Close access to "lsopen" for non-UI process
index dae29e1..a12249f 100644 (file)
@@ -82,6 +82,11 @@ private:
         return String::fromUTF8(m_session->priv->id.data());
     }
 
+    void didDisconnectFromRemote(WebAutomationSession&) override
+    {
+        webkitWebContextWillCloseAutomationSession(m_session->priv->webContext);
+    }
+
     void requestNewPageWithOptions(WebAutomationSession&, API::AutomationSessionBrowsingContextOptions, CompletionHandler<void(WebPageProxy*)>&& completionHandler) override
     {
         WebKitWebView* webView = nullptr;
index 134ca5c..b52591d 100644 (file)
@@ -242,6 +242,12 @@ private:
 
     WebKitWebContext* m_webContext;
 };
+
+void webkitWebContextWillCloseAutomationSession(WebKitWebContext* webContext)
+{
+    webContext->priv->processPool->setAutomationSession(nullptr);
+    webContext->priv->automationSession = nullptr;
+}
 #endif // ENABLE(REMOTE_INSPECTOR)
 
 WEBKIT_DEFINE_TYPE(WebKitWebContext, webkit_web_context, G_TYPE_OBJECT)
index 9583115..6adb52b 100644 (file)
@@ -47,3 +47,6 @@ void webkitWebContextWebViewDestroyed(WebKitWebContext*, WebKitWebView*);
 WebKitWebView* webkitWebContextGetWebViewForPage(WebKitWebContext*, WebKit::WebPageProxy*);
 GVariant* webkitWebContextInitializeWebExtensions(WebKitWebContext*);
 void webkitWebContextInitializeNotificationPermissions(WebKitWebContext*);
+#if ENABLE(REMOTE_INSPECTOR)
+void webkitWebContextWillCloseAutomationSession(WebKitWebContext*);
+#endif