From 161662dac8e14ccb76b90d86a2ed9f237b852be9 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Tue, 17 Nov 2015 13:55:31 +0000 Subject: [PATCH] Bug 1191468 - always load app dir add-ons irrespective of enabledScopes, r=Mossop,froydnj --HG-- extra : commitid : 4O0JNbchonb extra : rebase_source : f218722dd70f74a45e4dbb461a7faaa3ef1d1d81 extra : amend_source : 538b86815da89ccf5b3e7e42412019064123ccfe --- toolkit/mozapps/extensions/internal/XPIProvider.jsm | 10 ++++------ .../mozapps/extensions/test/xpcshell/head_addons.js | 10 ++++++++++ .../mozapps/extensions/test/xpcshell/test_upgrade.js | 2 +- .../test/xpcshell/test_upgrade_strictcompat.js | 2 +- toolkit/xre/nsXREDirProvider.cpp | 7 +++++++ xpcom/build/nsXULAppAPI.h | 6 ++++++ 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index 145c2d99e4bf..7553201b584a 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -134,7 +134,7 @@ const FILE_WEB_MANIFEST = "manifest.json"; const FILE_XPI_ADDONS_LIST = "extensions.ini"; const KEY_PROFILEDIR = "ProfD"; -const KEY_APPDIR = "XCurProcD"; +const KEY_ADDON_APP_DIR = "XREAddonAppDir"; const KEY_TEMPDIR = "TmpD"; const KEY_APP_DISTRIBUTION = "XREAppDist"; const KEY_APP_FEATURES = "XREAppFeat"; @@ -2567,11 +2567,9 @@ this.XPIProvider = { } } - if (enabledScopes & AddonManager.SCOPE_APPLICATION) { - addDirectoryInstallLocation(KEY_APP_GLOBAL, KEY_APPDIR, - [DIR_EXTENSIONS], - AddonManager.SCOPE_APPLICATION, true); - } + addDirectoryInstallLocation(KEY_APP_GLOBAL, KEY_ADDON_APP_DIR, + [DIR_EXTENSIONS], + AddonManager.SCOPE_APPLICATION, true); if (enabledScopes & AddonManager.SCOPE_SYSTEM) { addDirectoryInstallLocation(KEY_APP_SYSTEM_SHARE, "XRESysSExtPD", diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js index 200ce1e23863..dd654c687127 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js +++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js @@ -1658,6 +1658,12 @@ gTmpD.append("temp"); gTmpD.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); registerDirectory("TmpD", gTmpD); +// Create a replacement app directory for the tests. +const gAppDirForAddons = gProfD.clone(); +gAppDirForAddons.append("appdir-addons"); +gAppDirForAddons.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); +registerDirectory("XREAddonAppDir", gAppDirForAddons); + // Write out an empty blocklist.xml file to the profile to ensure nothing // is blocklisted by default var blockFile = gProfD.clone(); @@ -1721,6 +1727,10 @@ do_register_cleanup(function addon_cleanup() { } dirEntries.close(); + try { + gAppDirForAddons.remove(true); + } catch (ex) { do_print("Got exception removing addon app dir, " + ex); } + var testDir = gProfD.clone(); testDir.append("extensions"); testDir.append("trash"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js index f79789b68d28..dc3d9438a86d 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js @@ -15,7 +15,7 @@ Services.prefs.setIntPref("extensions.enabledScopes", const profileDir = gProfD.clone(); profileDir.append("extensions"); -const globalDir = Services.dirsvc.get("XCurProcD", AM_Ci.nsIFile); +const globalDir = Services.dirsvc.get("XREAddonAppDir", AM_Ci.nsIFile); globalDir.append("extensions"); var gGlobalExisted = globalDir.exists(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js index 69383166e652..c2203d097c5f 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js @@ -13,7 +13,7 @@ Services.prefs.setIntPref("extensions.enabledScopes", const profileDir = gProfD.clone(); profileDir.append("extensions"); -const globalDir = Services.dirsvc.get("XCurProcD", AM_Ci.nsIFile); +const globalDir = Services.dirsvc.get("XREAddonAppDir", AM_Ci.nsIFile); globalDir.append("extensions"); var gGlobalExisted = globalDir.exists(); diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index 475d36109647..2ac76686d630 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -394,6 +394,13 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent, if (NS_SUCCEEDED(rv)) rv = file->AppendNative(NS_LITERAL_CSTRING("features")); } + else if (!strcmp(aProperty, XRE_ADDON_APP_DIR)) { + nsCOMPtr dirsvc(do_GetService("@mozilla.org/file/directory_service;1", &rv)); + if (NS_FAILED(rv)) + return rv; + bool unused; + rv = dirsvc->GetFile("XCurProcD", &unused, getter_AddRefs(file)); + } else if (NS_SUCCEEDED(GetProfileStartupDir(getter_AddRefs(file)))) { // We need to allow component, xpt, and chrome registration to // occur prior to the profile-after-change notification. diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h index 3c94f7f21f28..bd87549251d6 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -123,6 +123,12 @@ */ #define XRE_APP_FEATURES_DIR "XREAppFeat" +/** + * A directory service key which specifies the location for app dir add-ons. + * Should be a synonym for XCurProcD everywhere except in tests. + */ +#define XRE_ADDON_APP_DIR "XREAddonAppDir" + /** * A directory service key which provides the update directory. * At present this is supported only on Windows.