mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 1498103: Avoid to add debug target listeners for USB runtime. r=jdescottes
When the addon was removed/added, REQUEST_EXTENSIONS_SUCCESS action was fired. But because current USB runtime does not support extensions debugging, we avoid to add debug target listener for USB runtime. Likewise, we refer the state of supporting for workers and tabs. Differential Revision: https://phabricator.services.mozilla.com/D9469 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
73bc6f9bc2
commit
7b111c9032
@ -7,10 +7,12 @@
|
||||
const { AddonManager } = require("resource://gre/modules/AddonManager.jsm");
|
||||
|
||||
const {
|
||||
DEBUG_TARGETS,
|
||||
UNWATCH_RUNTIME_START,
|
||||
WATCH_RUNTIME_SUCCESS,
|
||||
} = require("../constants");
|
||||
const Actions = require("../actions/index");
|
||||
const { isSupportedDebugTarget } = require("../modules/debug-target-support");
|
||||
|
||||
function debugTargetListenerMiddleware(store) {
|
||||
const onExtensionsUpdated = () => {
|
||||
@ -54,25 +56,45 @@ function debugTargetListenerMiddleware(store) {
|
||||
return next => action => {
|
||||
switch (action.type) {
|
||||
case WATCH_RUNTIME_SUCCESS: {
|
||||
const { client } = action.runtime.runtimeDetails;
|
||||
client.addListener("tabListChanged", onTabsUpdated);
|
||||
AddonManager.addAddonListener(extensionsListener);
|
||||
client.addListener("workerListChanged", onWorkersUpdated);
|
||||
client.addListener("serviceWorkerRegistrationListChanged", onWorkersUpdated);
|
||||
client.addListener("processListChanged", onWorkersUpdated);
|
||||
client.addListener("registration-changed", onWorkersUpdated);
|
||||
client.addListener("push-subscription-modified", onWorkersUpdated);
|
||||
const { runtime } = action;
|
||||
const { client } = runtime.runtimeDetails;
|
||||
|
||||
if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.TAB)) {
|
||||
client.addListener("tabListChanged", onTabsUpdated);
|
||||
}
|
||||
|
||||
if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.EXTENSION)) {
|
||||
AddonManager.addAddonListener(extensionsListener);
|
||||
}
|
||||
|
||||
if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.WORKER)) {
|
||||
client.addListener("workerListChanged", onWorkersUpdated);
|
||||
client.addListener("serviceWorkerRegistrationListChanged", onWorkersUpdated);
|
||||
client.addListener("processListChanged", onWorkersUpdated);
|
||||
client.addListener("registration-changed", onWorkersUpdated);
|
||||
client.addListener("push-subscription-modified", onWorkersUpdated);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case UNWATCH_RUNTIME_START: {
|
||||
const { client } = action.runtime.runtimeDetails;
|
||||
client.removeListener("tabListChanged", onTabsUpdated);
|
||||
AddonManager.removeAddonListener(extensionsListener);
|
||||
client.removeListener("workerListChanged", onWorkersUpdated);
|
||||
client.removeListener("serviceWorkerRegistrationListChanged", onWorkersUpdated);
|
||||
client.removeListener("processListChanged", onWorkersUpdated);
|
||||
client.removeListener("registration-changed", onWorkersUpdated);
|
||||
client.removeListener("push-subscription-modified", onWorkersUpdated);
|
||||
const { runtime } = action;
|
||||
const { client } = runtime.runtimeDetails;
|
||||
|
||||
if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.TAB)) {
|
||||
client.removeListener("tabListChanged", onTabsUpdated);
|
||||
}
|
||||
|
||||
if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.EXTENSION)) {
|
||||
AddonManager.removeAddonListener(extensionsListener);
|
||||
}
|
||||
|
||||
if (isSupportedDebugTarget(runtime.type, DEBUG_TARGETS.WORKER)) {
|
||||
client.removeListener("workerListChanged", onWorkersUpdated);
|
||||
client.removeListener("serviceWorkerRegistrationListChanged", onWorkersUpdated);
|
||||
client.removeListener("processListChanged", onWorkersUpdated);
|
||||
client.removeListener("registration-changed", onWorkersUpdated);
|
||||
client.removeListener("push-subscription-modified", onWorkersUpdated);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user