WebPageProxy::close() is a no-op for terminated processes
[WebKit-https.git] / Source / WebKit2 / UIProcess / WebPageProxy.cpp
index bc3703365233eda8ecf2d5030a2fa0e8b8048bc0..fbce8106552e18b4fe829824e798ee282efd17f8 100644 (file)
@@ -425,6 +425,12 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
 
 WebPageProxy::~WebPageProxy()
 {
 
 WebPageProxy::~WebPageProxy()
 {
+    ASSERT(m_process->webPage(m_pageID) != this);
+#if !ASSERT_DISABLED
+    for (WebPageProxy* page : m_process->pages())
+        ASSERT(page != this);
+#endif
+
     if (!m_isClosed)
         close();
 
     if (!m_isClosed)
         close();
 
@@ -546,6 +552,7 @@ void WebPageProxy::reattachToWebProcess()
 
     m_isValid = true;
     m_process->removeWebPage(m_pageID);
 
     m_isValid = true;
     m_process->removeWebPage(m_pageID);
+    m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID);
 
     if (m_process->context().processModel() == ProcessModelSharedSecondaryProcess)
         m_process = m_process->context().ensureSharedWebProcess();
 
     if (m_process->context().processModel() == ProcessModelSharedSecondaryProcess)
         m_process = m_process->context().ensureSharedWebProcess();
@@ -650,7 +657,7 @@ bool WebPageProxy::isProcessSuppressible() const
 
 void WebPageProxy::close()
 {
 
 void WebPageProxy::close()
 {
-    if (!isValid())
+    if (m_isClosed)
         return;
 
     m_isClosed = true;
         return;
 
     m_isClosed = true;
@@ -3133,6 +3140,8 @@ void WebPageProxy::connectionWillClose(IPC::Connection* connection)
 
 void WebPageProxy::processDidFinishLaunching()
 {
 
 void WebPageProxy::processDidFinishLaunching()
 {
+    ASSERT(m_process->state() == WebProcessProxy::State::Running);
+
     if (m_userContentController)
         m_userContentController->addProcess(m_process.get());
     m_visitedLinkProvider->addProcess(m_process.get());
     if (m_userContentController)
         m_userContentController->addProcess(m_process.get());
     m_visitedLinkProvider->addProcess(m_process.get());
@@ -4459,8 +4468,6 @@ void WebPageProxy::resetStateAfterProcessExited()
         m_visitedLinkProvider->removeProcess(m_process.get());
     }
 
         m_visitedLinkProvider->removeProcess(m_process.get());
     }
 
-    m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID);
-
 #if PLATFORM(IOS)
     m_activityToken = nullptr;
 #endif
 #if PLATFORM(IOS)
     m_activityToken = nullptr;
 #endif