Bug 1207287: Move the app-shipped system add-ons somewhere where they will be included in up date MARs. r=froydnj r=rhelmer
authorDave Townsend <dtownsend@oxymoronical.com>
Thu, 24 Sep 2015 16:03:01 -0700
changeset 264692 7344db584b26c5760582114f7a80e24a7b47aaaa
parent 264691 cc22ed2cafd3f850e00c3b16a45e6a24c1a190bc
child 264693 58adc6b9c8ea3d983ae82c22528fba244f9e5b51
push id65707
push usercbook@mozilla.com
push dateMon, 28 Sep 2015 12:18:34 +0000
treeherdermozilla-inbound@2c0e60a8f736 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, rhelmer
bugs1207287
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1207287: Move the app-shipped system add-ons somewhere where they will be included in up date MARs. r=froydnj r=rhelmer This moves the app-shipped system add-ons into <appdir>/features. I've created a new directory provider location for this since it allows us to override the location without allowing external apps to do so as would be the case with prefs.
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
toolkit/xre/nsXREDirProvider.cpp
xpcom/build/nsXULAppAPI.h
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -130,16 +130,17 @@ const FILE_OLD_CACHE                  = 
 const FILE_RDF_MANIFEST               = "install.rdf";
 const FILE_WEB_MANIFEST               = "manifest.json";
 const FILE_XPI_ADDONS_LIST            = "extensions.ini";
 
 const KEY_PROFILEDIR                  = "ProfD";
 const KEY_APPDIR                      = "XCurProcD";
 const KEY_TEMPDIR                     = "TmpD";
 const KEY_APP_DISTRIBUTION            = "XREAppDist";
+const KEY_APP_FEATURES                = "XREAppFeat";
 
 const KEY_APP_PROFILE                 = "app-profile";
 const KEY_APP_SYSTEM_ADDONS           = "app-system-addons";
 const KEY_APP_SYSTEM_DEFAULTS         = "app-system-defaults";
 const KEY_APP_GLOBAL                  = "app-global";
 const KEY_APP_SYSTEM_LOCAL            = "app-system-local";
 const KEY_APP_SYSTEM_SHARE            = "app-system-share";
 const KEY_APP_SYSTEM_USER             = "app-system-user";
@@ -2440,19 +2441,18 @@ this.XPIProvider = {
       addDirectoryInstallLocation(KEY_APP_PROFILE, KEY_PROFILEDIR,
                                   [DIR_EXTENSIONS],
                                   AddonManager.SCOPE_PROFILE, false);
 
       addSystemAddonInstallLocation(KEY_APP_SYSTEM_ADDONS, KEY_PROFILEDIR,
                                     [DIR_SYSTEM_ADDONS],
                                     AddonManager.SCOPE_PROFILE);
 
-      addDirectoryInstallLocation(KEY_APP_SYSTEM_DEFAULTS, KEY_APP_DISTRIBUTION,
-                                  [DIR_SYSTEM_ADDONS],
-                                  AddonManager.SCOPE_PROFILE, true);
+      addDirectoryInstallLocation(KEY_APP_SYSTEM_DEFAULTS, KEY_APP_FEATURES,
+                                  [], AddonManager.SCOPE_PROFILE, true);
 
       if (enabledScopes & AddonManager.SCOPE_USER) {
         addDirectoryInstallLocation(KEY_APP_SYSTEM_USER, "XREUSysExt",
                                     [Services.appinfo.ID],
                                     AddonManager.SCOPE_USER, true);
         if (hasRegistry) {
           addRegistryInstallLocation("winreg-app-user",
                                      Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
@@ -3,48 +3,41 @@
 const PREF_SYSTEM_ADDON_SET = "extensions.systemAddonSet";
 
 // Enable signature checks for these tests
 Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
 
 const featureDir = FileUtils.getDir("ProfD", ["features"]);
 
 // Build the test sets
-let dir = FileUtils.getDir("ProfD", ["sysfeatures", "app1", "features"], true);
+let dir = FileUtils.getDir("ProfD", ["sysfeatures", "app1"], true);
 do_get_file("data/system_addons/system1_1.xpi").copyTo(dir, "system1@tests.mozilla.org.xpi");
 do_get_file("data/system_addons/system2_1.xpi").copyTo(dir, "system2@tests.mozilla.org.xpi");
 
-dir = FileUtils.getDir("ProfD", ["sysfeatures", "app2", "features"], true);
+dir = FileUtils.getDir("ProfD", ["sysfeatures", "app2"], true);
 do_get_file("data/system_addons/system1_2.xpi").copyTo(dir, "system1@tests.mozilla.org.xpi");
 do_get_file("data/system_addons/system3_1.xpi").copyTo(dir, "system3@tests.mozilla.org.xpi");
 
-dir = FileUtils.getDir("ProfD", ["sysfeatures", "app3", "features"], true);
+dir = FileUtils.getDir("ProfD", ["sysfeatures", "app3"], true);
 do_get_file("data/system_addons/system1_1_badcert.xpi").copyTo(dir, "system1@tests.mozilla.org.xpi");
 do_get_file("data/system_addons/system3_1.xpi").copyTo(dir, "system3@tests.mozilla.org.xpi");
 
 const distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "app0"], true);
-registerDirectory("XREAppDist", distroDir);
+registerDirectory("XREAppFeat", distroDir);
 
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "0");
 
 function makeUUID() {
   let uuidGen = AM_Cc["@mozilla.org/uuid-generator;1"].
                 getService(AM_Ci.nsIUUIDGenerator);
   return uuidGen.generateUUID().toString();
 }
 
 function* check_installed(inProfile, ...versions) {
-  let expectedDir;
-  if (inProfile) {
-    expectedDir = featureDir;
-  }
-  else {
-    expectedDir = distroDir.clone();
-    expectedDir.append("features");
-  }
+  let expectedDir = inProfile ? featureDir : distroDir;
 
   for (let i = 0; i < versions.length; i++) {
     let id = "system" + (i + 1) + "@tests.mozilla.org";
     let addon = yield promiseAddonByID(id);
 
     if (versions[i]) {
       // Add-on should be installed
       do_check_neq(addon, null);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
@@ -8,16 +8,23 @@ const PREF_APP_UPDATE_ENABLED         = 
 Components.utils.import("resource://testing-common/httpd.js");
 const { computeHash } = Components.utils.import("resource://gre/modules/addons/ProductAddonChecker.jsm");
 
 // Enable signature checks for these tests
 //Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
 
 const featureDir = FileUtils.getDir("ProfD", ["features"]);
 
+function getCurrentFeatureDir() {
+  let dir = featureDir.clone();
+  let set = JSON.parse(Services.prefs.getCharPref(PREF_SYSTEM_ADDON_SET));
+  dir.append(set.directory);
+  return dir;
+}
+
 // Build the test sets
 let dir = FileUtils.getDir("ProfD", ["features", "prefilled"], true);
 do_get_file("data/system_addons/system2_2.xpi").copyTo(dir, "system2@tests.mozilla.org.xpi");
 do_get_file("data/system_addons/system3_2.xpi").copyTo(dir, "system3@tests.mozilla.org.xpi");
 
 // Mark these in the past so the startup file scan notices when files have changed properly
 FileUtils.getFile("ProfD", ["features", "prefilled", "system2@tests.mozilla.org.xpi"]).lastModifiedTime -= 10000;
 FileUtils.getFile("ProfD", ["features", "prefilled", "system3@tests.mozilla.org.xpi"]).lastModifiedTime -= 10000;
@@ -30,26 +37,26 @@ const prefilledSet = {
       version: "2.0"
     },
     "system3@tests.mozilla.org": {
       version: "2.0"
     },
   }
 };
 
-dir = FileUtils.getDir("ProfD", ["sysfeatures", "hidden", "features"], true);
+dir = FileUtils.getDir("ProfD", ["sysfeatures", "hidden"], true);
 do_get_file("data/system_addons/system1_1.xpi").copyTo(dir, "system1@tests.mozilla.org.xpi");
 do_get_file("data/system_addons/system2_1.xpi").copyTo(dir, "system2@tests.mozilla.org.xpi");
 
-dir = FileUtils.getDir("ProfD", ["sysfeatures", "prefilled", "features"], true);
+dir = FileUtils.getDir("ProfD", ["sysfeatures", "prefilled"], true);
 do_get_file("data/system_addons/system2_2.xpi").copyTo(dir, "system2@tests.mozilla.org.xpi");
 do_get_file("data/system_addons/system3_2.xpi").copyTo(dir, "system3@tests.mozilla.org.xpi");
 
 const distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "empty"], true);
-registerDirectory("XREAppDist", distroDir);
+registerDirectory("XREAppFeat", distroDir);
 
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2");
 
 let testserver = new HttpServer();
 testserver.registerDirectory("/data/", do_get_file("data/system_addons"));
 testserver.start();
 let root = testserver.identity.primaryScheme + "://" +
            testserver.identity.primaryHost + ":" +
@@ -123,44 +130,39 @@ function* build_xml(addons) {
     xml += `  </addons>\n`;
   }
   xml += `</updates>\n`;
 
   return xml;
 }
 
 function* check_installed(inProfile, ...versions) {
+  let expectedDir = inProfile ? getCurrentFeatureDir() : distroDir;
+
   for (let i = 0; i < versions.length; i++) {
     let id = "system" + (i + 1) + "@tests.mozilla.org";
     let addon = yield promiseAddonByID(id);
 
     if (versions[i]) {
       // Add-on should be installed
       do_check_neq(addon, null);
       do_check_eq(addon.version, versions[i]);
       do_check_true(addon.isActive);
       do_check_false(addon.foreignInstall);
       go_check_true(addon.hidden);
 
       // Verify the add-ons file is in the right place
+      let file = expectedDir.clone();
+      file.append(id + ".xpi");
+      do_check_true(file.exists());
+      do_check_true(file.isFile());
+
       let uri = addon.getResourceURI(null);
       do_check_true(uri instanceof AM_Ci.nsIFileURL);
-
-      let file = uri.file.parent;
-      if (inProfile) {
-        file = file.parent;
-        do_check_eq(file.leafName, "features");
-        file = file.parent;
-        do_check_eq(file.path, gProfD.path);
-      }
-      else {
-        do_check_eq(file.leafName, "features");
-        file = file.parent;
-        do_check_eq(file.path, distroDir.path);
-      }
+      do_check_eq(uri.file.path, file.path);
 
       //do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SYSTEM);
 
       // Verify the add-on actually started
       let installed = Services.prefs.getCharPref("bootstraptest." + id + ".active_version");
       do_check_eq(installed, versions[i]);
     }
     else {
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -384,16 +384,21 @@ nsXREDirProvider::GetFile(const char* aP
 #endif
   }
   else if (!strcmp(aProperty, XRE_APP_DISTRIBUTION_DIR)) {
     bool persistent = false;
     rv = GetFile(NS_GRE_DIR, &persistent, getter_AddRefs(file));
     if (NS_SUCCEEDED(rv))
       rv = file->AppendNative(NS_LITERAL_CSTRING("distribution"));
   }
+  else if (!strcmp(aProperty, XRE_APP_FEATURES_DIR)) {
+    rv = GetAppDir()->Clone(getter_AddRefs(file));
+    if (NS_SUCCEEDED(rv))
+      rv = file->AppendNative(NS_LITERAL_CSTRING("features"));
+  }
   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.
     if (!strcmp(aProperty, NS_APP_USER_CHROME_DIR)) {
       rv = file->AppendNative(NS_LITERAL_CSTRING("chrome"));
     }
   }
 
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -114,16 +114,21 @@
 
 /**
  * A directory service key which specifies the distribution specific files for
  * the application.
  */
 #define XRE_APP_DISTRIBUTION_DIR "XREAppDist"
 
 /**
+ * A directory service key which specifies the location for system add-ons.
+ */
+#define XRE_APP_FEATURES_DIR "XREAppFeat"
+
+/**
  * A directory service key which provides the update directory.
  * At present this is supported only on Windows.
  * Windows: Documents and Settings\<User>\Local Settings\Application Data\
  *          <Vendor>\<Application>\<relative path to app dir from Program Files>
  * If appDir is not under the Program Files, directory service will fail.
  * Callers should fallback to appDir.
  */
 #define XRE_UPDATE_ROOT_DIR "UpdRootD"