Title: [179282] trunk/Source/WebKit2
Revision
179282
Author
[email protected]
Date
2015-01-28 13:24:13 -0800 (Wed, 28 Jan 2015)

Log Message

Web Inspector: Crash when closing inspected page
https://bugs.webkit.org/show_bug.cgi?id=140968

Patch by Joseph Pecoraro <[email protected]> on 2015-01-28
Reviewed by Timothy Hatcher.

Handle cases where the corePage could be null. With the Inspector Process
in its own process, messages may come to the WebContentProcess after
the WebCore::Page has itself been destroyed.

* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::show):
(WebKit::WebInspector::close):
(WebKit::WebInspector::openInNewTab):
(WebKit::WebInspector::evaluateScriptForTest):
(WebKit::WebInspector::showConsole):
(WebKit::WebInspector::showResources):
(WebKit::WebInspector::showMainResourceForFrame):
(WebKit::WebInspector::startPageProfiling):
(WebKit::WebInspector::stopPageProfiling):
(WebKit::WebInspector::canAttachWindow):
(WebKit::WebInspector::sendMessageToBackend):
(WebKit::WebInspector::remoteFrontendConnected):
(WebKit::WebInspector::remoteFrontendDisconnected):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (179281 => 179282)


--- trunk/Source/WebKit2/ChangeLog	2015-01-28 21:16:56 UTC (rev 179281)
+++ trunk/Source/WebKit2/ChangeLog	2015-01-28 21:24:13 UTC (rev 179282)
@@ -1,3 +1,29 @@
+2015-01-28  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Crash when closing inspected page
+        https://bugs.webkit.org/show_bug.cgi?id=140968
+
+        Reviewed by Timothy Hatcher.
+
+        Handle cases where the corePage could be null. With the Inspector Process
+        in its own process, messages may come to the WebContentProcess after
+        the WebCore::Page has itself been destroyed.
+
+        * WebProcess/WebPage/WebInspector.cpp:
+        (WebKit::WebInspector::show):
+        (WebKit::WebInspector::close):
+        (WebKit::WebInspector::openInNewTab):
+        (WebKit::WebInspector::evaluateScriptForTest):
+        (WebKit::WebInspector::showConsole):
+        (WebKit::WebInspector::showResources):
+        (WebKit::WebInspector::showMainResourceForFrame):
+        (WebKit::WebInspector::startPageProfiling):
+        (WebKit::WebInspector::stopPageProfiling):
+        (WebKit::WebInspector::canAttachWindow):
+        (WebKit::WebInspector::sendMessageToBackend):
+        (WebKit::WebInspector::remoteFrontendConnected):
+        (WebKit::WebInspector::remoteFrontendDisconnected):
+
 2015-01-28  Sam Weinig  <[email protected]>
 
         Convert WebPreferences and VisitedLinkProvider to be bridged API::Objects

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp (179281 => 179282)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp	2015-01-28 21:16:56 UTC (rev 179281)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp	2015-01-28 21:24:13 UTC (rev 179282)
@@ -114,17 +114,26 @@
 // Called by WebInspector messages
 void WebInspector::show()
 {
+    if (!m_page->corePage())
+        return;
+
     m_page->corePage()->inspectorController().show();
 }
 
 void WebInspector::close()
 {
+    if (!m_page->corePage())
+        return;
+
     m_page->corePage()->inspectorController().close();
 }
 
 void WebInspector::openInNewTab(const String& urlString)
 {
     Page* inspectedPage = m_page->corePage();
+    if (!inspectedPage)
+        return;
+
     Frame& inspectedMainFrame = inspectedPage->mainFrame();
     FrameLoadRequest request(inspectedMainFrame.document()->securityOrigin(), ResourceRequest(urlString), "_blank");
 
@@ -137,17 +146,26 @@
 
 void WebInspector::evaluateScriptForTest(const String& script)
 {
+    if (!m_page->corePage())
+        return;
+
     m_page->corePage()->inspectorController().evaluateForTestInFrontend(script);
 }
 
 void WebInspector::showConsole()
 {
+    if (!m_page->corePage())
+        return;
+
     m_page->corePage()->inspectorController().show();
     m_frontendConnection->send(Messages::WebInspectorUI::ShowConsole(), 0);
 }
 
 void WebInspector::showResources()
 {
+    if (!m_page->corePage())
+        return;
+
     m_page->corePage()->inspectorController().show();
     m_frontendConnection->send(Messages::WebInspectorUI::ShowResources(), 0);
 }
@@ -158,6 +176,9 @@
     if (!frame)
         return;
 
+    if (!m_page->corePage())
+        return;
+
     m_page->corePage()->inspectorController().show();
 
     String inspectorFrameIdentifier = m_page->corePage()->inspectorController().pageAgent()->frameId(frame->coreFrame());
@@ -166,18 +187,27 @@
 
 void WebInspector::startPageProfiling()
 {
+    if (!m_page->corePage())
+        return;
+
     m_page->corePage()->inspectorController().show();
     m_frontendConnection->send(Messages::WebInspectorUI::StartPageProfiling(), 0);
 }
 
 void WebInspector::stopPageProfiling()
 {
+    if (!m_page->corePage())
+        return;
+
     m_page->corePage()->inspectorController().show();
     m_frontendConnection->send(Messages::WebInspectorUI::StopPageProfiling(), 0);
 }
 
 bool WebInspector::canAttachWindow()
 {
+    if (!m_page->corePage())
+        return false;
+
     // Don't allow attaching to another inspector -- two inspectors in one window is too much!
     if (m_page->isInspectorPage())
         return false;
@@ -209,6 +239,9 @@
 
 void WebInspector::sendMessageToBackend(const String& message)
 {
+    if (!m_page->corePage())
+        return;
+
     m_page->corePage()->inspectorController().dispatchMessageFromFrontend(message);
 }
 
@@ -226,15 +259,19 @@
 #if ENABLE(INSPECTOR_SERVER)
 void WebInspector::remoteFrontendConnected()
 {
-    m_remoteFrontendConnected = true;
-    bool isAutomaticInspection = false;
-    m_page->corePage()->inspectorController().connectFrontend(this, isAutomaticInspection);
+    if (m_page->corePage()) {
+        m_remoteFrontendConnected = true;
+        bool isAutomaticInspection = false;
+        m_page->corePage()->inspectorController().connectFrontend(this, isAutomaticInspection);
+    }
 }
 
 void WebInspector::remoteFrontendDisconnected()
 {
     m_remoteFrontendConnected = false;
-    m_page->corePage()->inspectorController().disconnectFrontend(Inspector::InspectorDisconnectReason::InspectorDestroyed);
+
+    if (m_page->corePage())
+        m_page->corePage()->inspectorController().disconnectFrontend(Inspector::InspectorDisconnectReason::InspectorDestroyed);
 }
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to