Title: [285771] trunk/Source/WebCore
Revision
285771
Author
timo...@apple.com
Date
2021-11-12 19:22:14 -0800 (Fri, 12 Nov 2021)

Log Message

webView._isBeingInspected does not work with Service Worker pages
https://bugs.webkit.org/show_bug.cgi?id=233062
rdar://problem/85354982

Reviewed by Devin Rousso.

* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::connectFrontend): Call updateServiceWorkerPageFrontendCount().
(WebCore::WorkerInspectorController::disconnectFrontend): Ditto.
(WebCore::WorkerInspectorController::updateServiceWorkerPageFrontendCount): Added.
* inspector/WorkerInspectorController.h: Added updateServiceWorkerPageFrontendCount().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285770 => 285771)


--- trunk/Source/WebCore/ChangeLog	2021-11-13 02:26:18 UTC (rev 285770)
+++ trunk/Source/WebCore/ChangeLog	2021-11-13 03:22:14 UTC (rev 285771)
@@ -1,3 +1,17 @@
+2021-11-12  Timothy Hatcher  <timo...@apple.com>
+
+        webView._isBeingInspected does not work with Service Worker pages
+        https://bugs.webkit.org/show_bug.cgi?id=233062
+        rdar://problem/85354982
+
+        Reviewed by Devin Rousso.
+
+        * inspector/WorkerInspectorController.cpp:
+        (WebCore::WorkerInspectorController::connectFrontend): Call updateServiceWorkerPageFrontendCount().
+        (WebCore::WorkerInspectorController::disconnectFrontend): Ditto.
+        (WebCore::WorkerInspectorController::updateServiceWorkerPageFrontendCount): Added.
+        * inspector/WorkerInspectorController.h: Added updateServiceWorkerPageFrontendCount().
+
 2021-11-12  Darin Adler  <da...@apple.com>
 
         Make sort-Xcode-project-file idempotent

Modified: trunk/Source/WebCore/inspector/WorkerInspectorController.cpp (285770 => 285771)


--- trunk/Source/WebCore/inspector/WorkerInspectorController.cpp	2021-11-13 02:26:18 UTC (rev 285770)
+++ trunk/Source/WebCore/inspector/WorkerInspectorController.cpp	2021-11-13 03:22:14 UTC (rev 285771)
@@ -48,6 +48,8 @@
 #include <_javascript_Core/InspectorFrontendRouter.h>
 
 #if ENABLE(SERVICE_WORKER)
+#include "InspectorClient.h"
+#include "Page.h"
 #include "ServiceWorkerAgent.h"
 #include "ServiceWorkerGlobalScope.h"
 #endif
@@ -109,6 +111,10 @@
     m_forwardingChannel = makeUnique<WorkerToPageFrontendChannel>(m_globalScope);
     m_frontendRouter->connectFrontend(*m_forwardingChannel.get());
     m_agents.didCreateFrontendAndBackend(&m_frontendRouter.get(), &m_backendDispatcher.get());
+
+#if ENABLE(SERVICE_WORKER)
+    updateServiceWorkerPageFrontendCount();
+#endif
 }
 
 void WorkerInspectorController::disconnectFrontend(Inspector::DisconnectReason reason)
@@ -125,8 +131,34 @@
     m_agents.willDestroyFrontendAndBackend(reason);
     m_frontendRouter->disconnectFrontend(*m_forwardingChannel.get());
     m_forwardingChannel = nullptr;
+
+#if ENABLE(SERVICE_WORKER)
+    updateServiceWorkerPageFrontendCount();
+#endif
 }
 
+#if ENABLE(SERVICE_WORKER)
+void WorkerInspectorController::updateServiceWorkerPageFrontendCount()
+{
+    if (!is<ServiceWorkerGlobalScope>(m_globalScope))
+        return;
+
+    auto serviceWorkerPage = downcast<ServiceWorkerGlobalScope>(m_globalScope).serviceWorkerPage();
+    if (!serviceWorkerPage)
+        return;
+
+    ASSERT(isMainThread());
+
+    // When a service worker is loaded in a Page, we need to report its inspector frontend count
+    // up to the page's inspectorController so the client knows about it.
+    auto inspectorClient = serviceWorkerPage->inspectorController().inspectorClient();
+    if (!inspectorClient)
+        return;
+
+    inspectorClient->frontendCountChanged(m_frontendRouter->frontendCount());
+}
+#endif
+
 void WorkerInspectorController::dispatchMessageFromFrontend(const String& message)
 {
     m_backendDispatcher->dispatch(message);

Modified: trunk/Source/WebCore/inspector/WorkerInspectorController.h (285770 => 285771)


--- trunk/Source/WebCore/inspector/WorkerInspectorController.h	2021-11-13 02:26:18 UTC (rev 285770)
+++ trunk/Source/WebCore/inspector/WorkerInspectorController.h	2021-11-13 03:22:14 UTC (rev 285771)
@@ -74,6 +74,10 @@
     WorkerAgentContext workerAgentContext();
     void createLazyAgents();
 
+#if ENABLE(SERVICE_WORKER)
+    void updateServiceWorkerPageFrontendCount();
+#endif
+
     Ref<InstrumentingAgents> m_instrumentingAgents;
     std::unique_ptr<WebInjectedScriptManager> m_injectedScriptManager;
     Ref<Inspector::FrontendRouter> m_frontendRouter;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to