From 3f442e7f6688deb84d78911b119e4ca2cd49100c Mon Sep 17 00:00:00 2001 From: Tomislav Jovanovic Date: Sat, 20 Nov 2021 13:10:58 +0000 Subject: [PATCH] Bug 1708193 - Remove mozapps/extensions/internal/Content.js r=rpl Use Extension:FlushJarCache listener in ExtensionProcessScript.jsm instead, it's already loaded everywhere and early enough from AddonManager.jsm. Differential Revision: https://phabricator.services.mozilla.com/D129952 --- .../test/performance/browser_startup_content.js | 3 --- dom/base/nsFrameMessageManager.h | 5 +--- toolkit/mozapps/extensions/addonManager.js | 3 --- toolkit/mozapps/extensions/internal/Content.js | 31 ---------------------- toolkit/mozapps/extensions/internal/XPIInstall.jsm | 6 +++-- toolkit/mozapps/extensions/internal/moz.build | 1 - 6 files changed, 5 insertions(+), 44 deletions(-) delete mode 100644 toolkit/mozapps/extensions/internal/Content.js diff --git a/browser/base/content/test/performance/browser_startup_content.js b/browser/base/content/test/performance/browser_startup_content.js index c5aa864a0c87..4fd4c6da22ee 100644 --- a/browser/base/content/test/performance/browser_startup_content.js +++ b/browser/base/content/test/performance/browser_startup_content.js @@ -51,9 +51,6 @@ const known_scripts = { frameScripts: new Set([ // Test related "chrome://mochikit/content/shutdown-leaks-collector.js", - - // Extensions - "resource://gre/modules/addons/Content.js", ]), processScripts: new Set([ "chrome://global/content/process-content.js", diff --git a/dom/base/nsFrameMessageManager.h b/dom/base/nsFrameMessageManager.h index 739ee5365df1..8316a6710176 100644 --- a/dom/base/nsFrameMessageManager.h +++ b/dom/base/nsFrameMessageManager.h @@ -362,16 +362,13 @@ class nsScriptCacheCleaner final : public nsIObserver { nsCOMPtr obsSvc = mozilla::services::GetObserverService(); if (obsSvc) { - obsSvc->AddObserver(this, "message-manager-flush-caches", false); obsSvc->AddObserver(this, "xpcom-shutdown", false); } } NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) override { - if (strcmp("message-manager-flush-caches", aTopic) == 0) { - nsMessageManagerScriptExecutor::PurgeCache(); - } else if (strcmp("xpcom-shutdown", aTopic) == 0) { + if (strcmp("xpcom-shutdown", aTopic) == 0) { nsMessageManagerScriptExecutor::Shutdown(); } return NS_OK; diff --git a/toolkit/mozapps/extensions/addonManager.js b/toolkit/mozapps/extensions/addonManager.js index c147f2de2bba..c45be21dff28 100644 --- a/toolkit/mozapps/extensions/addonManager.js +++ b/toolkit/mozapps/extensions/addonManager.js @@ -45,8 +45,6 @@ const MSG_INSTALL_CLEANUP = "WebAPICleanup"; const MSG_ADDON_EVENT_REQ = "WebAPIAddonEventRequest"; const MSG_ADDON_EVENT = "WebAPIAddonEvent"; -const CHILD_SCRIPT = "resource://gre/modules/addons/Content.js"; - const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); var gSingleton = null; @@ -57,7 +55,6 @@ function amManager() { "resource://gre/modules/AddonManager.jsm" )); - Services.mm.loadFrameScript(CHILD_SCRIPT, true, true); Services.mm.addMessageListener(MSG_INSTALL_ENABLED, this); Services.mm.addMessageListener(MSG_PROMISE_REQUEST, this); Services.mm.addMessageListener(MSG_INSTALL_CLEANUP, this); diff --git a/toolkit/mozapps/extensions/internal/Content.js b/toolkit/mozapps/extensions/internal/Content.js deleted file mode 100644 index 7296309cf2cd..000000000000 --- a/toolkit/mozapps/extensions/internal/Content.js +++ /dev/null @@ -1,31 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* globals addMessageListener*/ - -"use strict"; - -(function() { - var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); - - const MSG_JAR_FLUSH = "AddonJarFlush"; - const MSG_MESSAGE_MANAGER_CACHES_FLUSH = "AddonMessageManagerCachesFlush"; - - try { - if ( - Services.appinfo.processType !== Services.appinfo.PROCESS_TYPE_DEFAULT - ) { - // Propagate JAR cache flush notifications across process boundaries. - addMessageListener(MSG_JAR_FLUSH, function(message) { - Services.obs.notifyObservers(null, "flush-cache-entry", message.data); - }); - // Propagate message manager caches flush notifications across processes. - addMessageListener(MSG_MESSAGE_MANAGER_CACHES_FLUSH, function() { - Services.obs.notifyObservers(null, "message-manager-flush-caches"); - }); - } - } catch (e) { - Cu.reportError(e); - } -})(); diff --git a/toolkit/mozapps/extensions/internal/XPIInstall.jsm b/toolkit/mozapps/extensions/internal/XPIInstall.jsm index 00fc39509bff..5c0242328d07 100644 --- a/toolkit/mozapps/extensions/internal/XPIInstall.jsm +++ b/toolkit/mozapps/extensions/internal/XPIInstall.jsm @@ -172,7 +172,9 @@ function getFile(path, base = null) { */ function flushJarCache(aJarFile) { Services.obs.notifyObservers(aJarFile, "flush-cache-entry"); - Services.mm.broadcastAsyncMessage(MSG_JAR_FLUSH, aJarFile.path); + Services.ppmm.broadcastAsyncMessage(MSG_JAR_FLUSH, { + path: aJarFile.path, + }); } const PREF_EM_UPDATE_BACKGROUND_URL = "extensions.update.background.url"; @@ -189,7 +191,7 @@ const TEMP_INSTALL_ID_GEN_SESSION = new Uint8Array( Float64Array.of(Math.random()).buffer ); -const MSG_JAR_FLUSH = "AddonJarFlush"; +const MSG_JAR_FLUSH = "Extension:FlushJarCache"; /** * Valid IDs fit this pattern. diff --git a/toolkit/mozapps/extensions/internal/moz.build b/toolkit/mozapps/extensions/internal/moz.build index 4ee2452b31f4..6d34f51c35f8 100644 --- a/toolkit/mozapps/extensions/internal/moz.build +++ b/toolkit/mozapps/extensions/internal/moz.build @@ -8,7 +8,6 @@ EXTRA_JS_MODULES.addons += [ "AddonRepository.jsm", "AddonSettings.jsm", "AddonUpdateChecker.jsm", - "Content.js", "ProductAddonChecker.jsm", "XPIDatabase.jsm", "XPIInstall.jsm", -- 2.11.4.GIT