diff --git a/devtools/client/aboutdebugging-new/src/middleware/debug-target-listener.js b/devtools/client/aboutdebugging-new/src/middleware/debug-target-listener.js index da80dc2315d0..bd64e6a2c33d 100644 --- a/devtools/client/aboutdebugging-new/src/middleware/debug-target-listener.js +++ b/devtools/client/aboutdebugging-new/src/middleware/debug-target-listener.js @@ -41,6 +41,10 @@ function debugTargetListenerMiddleware(store) { if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.WORKER)) { clientWrapper.addListener("workerListChanged", onWorkersUpdated); + clientWrapper.onFront("contentProcessTarget", front => { + clientWrapper.contentProcessFronts.push(front); + front.on("workerListChanged", onWorkersUpdated); + }); clientWrapper.addListener("serviceWorkerRegistrationListChanged", onWorkersUpdated); clientWrapper.addListener("processListChanged", onWorkersUpdated); @@ -65,6 +69,12 @@ function debugTargetListenerMiddleware(store) { clientWrapper.removeListener("workerListChanged", onWorkersUpdated); clientWrapper.removeListener("serviceWorkerRegistrationListChanged", onWorkersUpdated); + + for (const front of clientWrapper.contentProcessFronts) { + front.off("workerListChanged", onWorkersUpdated); + } + clientWrapper.contentProcessFronts = []; + clientWrapper.removeListener("processListChanged", onWorkersUpdated); clientWrapper.removeListener("registration-changed", onWorkersUpdated); clientWrapper.removeListener("push-subscription-modified", onWorkersUpdated); diff --git a/devtools/client/aboutdebugging-new/src/modules/client-wrapper.js b/devtools/client/aboutdebugging-new/src/modules/client-wrapper.js index c5d31b3773e3..f416ec8f77a6 100644 --- a/devtools/client/aboutdebugging-new/src/modules/client-wrapper.js +++ b/devtools/client/aboutdebugging-new/src/modules/client-wrapper.js @@ -31,6 +31,8 @@ const MAIN_ROOT_EVENTS = [ class ClientWrapper { constructor(client) { this.client = client; + // Array of contentProcessTarget fronts on which we will listen for worker events. + this.contentProcessFronts = []; } addOneTimeListener(evt, listener) { @@ -57,6 +59,10 @@ class ClientWrapper { } } + onFront(typeName, listener) { + this.client.mainRoot.onFront(typeName, listener); + } + async getDeviceDescription() { const deviceFront = await this.client.mainRoot.getFront("device"); const { brandName, channel, deviceName, version } = diff --git a/devtools/client/aboutdebugging-new/test/browser/mocks/head-client-wrapper-mock.js b/devtools/client/aboutdebugging-new/test/browser/mocks/head-client-wrapper-mock.js index 175a27039b0d..33b310fb18db 100644 --- a/devtools/client/aboutdebugging-new/test/browser/mocks/head-client-wrapper-mock.js +++ b/devtools/client/aboutdebugging-new/test/browser/mocks/head-client-wrapper-mock.js @@ -75,6 +75,8 @@ function createClientMock() { serviceWorkers: [], sharedWorkers: [], }), + // no-op + onFront: () => {}, // stores the preference locally (doesn't update about:config) setPreference: function(prefName, value) { this._preferences[prefName] = value;