Web Automation: terminate the automation session if the web process crashes
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Nov 2016 22:24:33 +0000 (22:24 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Nov 2016 22:24:33 +0000 (22:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164671
<rdar://problem/29028964>

Reviewed by Joseph Pecoraro.

* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::disconnect):
(WebKit::WebAutomationSession::terminate):
Factor out code that disconnects the remote, unpairs, and notifies the client.
Then, expose terminate() which can be called without a FrontendChannel.
Calling this causes the _WKAutomationDelegate to clear the local-side session in the
browser, and disconnecting from the remote will hang up the remote-side session.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::processDidCrash):
Terminate the session.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp
Source/WebKit2/UIProcess/Automation/WebAutomationSession.h
Source/WebKit2/UIProcess/WebPageProxy.cpp

index a55635a..ae8cf43 100644 (file)
@@ -1,3 +1,24 @@
+2016-11-12  Brian Burg  <bburg@apple.com>
+
+        Web Automation: terminate the automation session if the web process crashes
+        https://bugs.webkit.org/show_bug.cgi?id=164671
+        <rdar://problem/29028964>
+
+        Reviewed by Joseph Pecoraro.
+
+        * UIProcess/Automation/WebAutomationSession.h:
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::disconnect):
+        (WebKit::WebAutomationSession::terminate):
+        Factor out code that disconnects the remote, unpairs, and notifies the client.
+        Then, expose terminate() which can be called without a FrontendChannel.
+        Calling this causes the _WKAutomationDelegate to clear the local-side session in the
+        browser, and disconnecting from the remote will hang up the remote-side session.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::processDidCrash):
+        Terminate the session.
+
 2016-11-11  Alex Christensen  <achristensen@webkit.org>
 
         Use SecurityOriginData as keys in StorageManager
index 27b1f16..8232314 100644 (file)
@@ -129,18 +129,26 @@ void WebAutomationSession::connect(Inspector::FrontendChannel* channel, bool isA
 void WebAutomationSession::disconnect(Inspector::FrontendChannel* channel)
 {
     ASSERT(channel == m_remoteChannel);
+    terminate();
+}
+
+#endif // ENABLE(REMOTE_INSPECTOR)
 
-    m_remoteChannel = nullptr;
-    m_frontendRouter->disconnectFrontend(channel);
+void WebAutomationSession::terminate()
+{
+#if ENABLE(REMOTE_INSPECTOR)
+    if (Inspector::FrontendChannel* channel = m_remoteChannel) {
+        m_remoteChannel = nullptr;
+        m_frontendRouter->disconnectFrontend(channel);
+    }
 
     setIsPaired(false);
+#endif
 
     if (m_client)
         m_client->didDisconnectFromRemote(this);
 }
 
-#endif // ENABLE(REMOTE_INSPECTOR)
-
 WebPageProxy* WebAutomationSession::webPageProxyForHandle(const String& handle)
 {
     auto iter = m_handleWebPageMap.find(handle);
index 280d2d5..6a8d050 100644 (file)
@@ -93,6 +93,7 @@ public:
     void connect(Inspector::FrontendChannel*, bool isAutomaticConnection = false) override;
     void disconnect(Inspector::FrontendChannel*) override;
 #endif
+    void terminate();
 
     // Inspector::AutomationBackendDispatcherHandler API
     void getBrowsingContexts(Inspector::ErrorString&, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingContext>>&) override;
index e021b03..c0353c6 100644 (file)
@@ -5287,6 +5287,11 @@ void WebPageProxy::processDidCrash()
         m_navigationClient->processDidCrash(*this);
     else
         m_loaderClient->processDidCrash(*this);
+
+    if (m_controlledByAutomation) {
+        if (auto* automationSession = process().processPool().automationSession())
+            automationSession->terminate();
+    }
 }
 
 #if PLATFORM(IOS)