Bug 1193926: Only register chrome for add-ons that need it. r=bsmedberg

--HG--
extra : commitid : KRQXLPhcfl
extra : rebase_source : 9fac383d4624e8dbd670bbd3e70caaa346c84bf9
extra : amend_source : fd31d377fbbf8ef63a99bc0ef041a27237040f67
This commit is contained in:
Dave Townsend 2015-08-24 09:36:57 -07:00
parent 4053192f59
commit 3367215de0
5 changed files with 29 additions and 2 deletions

View File

@ -209,6 +209,11 @@ const TYPE_ALIASES = {
"webextension": "extension",
};
const CHROME_TYPES = new Set([
"extension",
"locale",
]);
const RESTARTLESS_TYPES = new Set([
"webextension",
"dictionary",
@ -4733,7 +4738,7 @@ this.XPIProvider = {
}
let timeStart = new Date();
if (aMethod == "startup") {
if (CHROME_TYPES.has(aAddon.type) && aMethod == "startup") {
logger.debug("Registering manifest for " + aFile.path);
Components.manager.addBootstrappedManifestLocation(aFile);
}
@ -4776,7 +4781,7 @@ this.XPIProvider = {
}
}
finally {
if (aMethod == "shutdown" && aReason != BOOTSTRAP_REASONS.APP_SHUTDOWN) {
if (CHROME_TYPES.has(aAddon.type) && aMethod == "shutdown" && aReason != BOOTSTRAP_REASONS.APP_SHUTDOWN) {
logger.debug("Removing manifest for " + aFile.path);
Components.manager.removeBootstrappedManifestLocation(aFile);

View File

@ -0,0 +1 @@
content dict ./

View File

@ -0,0 +1 @@
content webex ./

View File

@ -175,6 +175,16 @@ function check_test_1() {
let dir = do_get_addon_root_uri(profileDir, "ab-CD@dictionaries.addons.mozilla.org");
let chromeReg = AM_Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(AM_Ci.nsIChromeRegistry);
try {
chromeReg.convertChromeURL(NetUtil.newURI("chrome://dict/content/dict.xul"));
do_throw("Chrome manifest should not have been registered");
}
catch (e) {
// Expected the chrome url to not be registered
}
AddonManager.getAddonsWithOperationsByTypes(null, function(list) {
do_check_eq(list.length, 0);

View File

@ -35,6 +35,16 @@ add_task(function*() {
do_check_eq(GlobalManager.count, 1);
do_check_true(GlobalManager.extensionMap.has(ID));
let chromeReg = AM_Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(AM_Ci.nsIChromeRegistry);
try {
chromeReg.convertChromeURL(NetUtil.newURI("chrome://webex/content/webex.xul"));
do_throw("Chrome manifest should not have been registered");
}
catch (e) {
// Expected the chrome url to not be registered
}
let addon = yield promiseAddonByID(ID);
do_check_neq(addon, null);
do_check_eq(addon.version, "1.0");