Bug 1350064 - test that updated system add-ons are reset on app update r=aswan a=gchang
authorRobert Helmer <rhelmer@mozilla.com>
Thu, 23 Mar 2017 18:49:58 -0700
changeset 379296 6c66fac00e392e08121d905e27e461bdccd853ea
parent 379295 5ab83d9424cdb60ccbbdcb2849f640f06e4fd9a8
child 379297 f758f44a68deac39fe3bc178f1f4da0ea0118b48
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan, gchang
bugs1350064
milestone53.0
Bug 1350064 - test that updated system add-ons are reset on app update r=aswan a=gchang MozReview-Commit-ID: BbUtIMfCDXZ
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -8585,25 +8585,31 @@ Object.assign(SystemAddonInstallLocation
 
     return true;
   },
 
   /**
    * Resets the add-on set so on the next startup the default set will be used.
    */
   resetAddonSet() {
-
+    logger.info("Removing all system add-on upgrades.");
+
+    // remove everything from the pref first, if uninstall
+    // fails then at least they will not be re-activated on
+    // next restart.
+    this._saveAddonSet({ schema: 1, addons: {} });
+
+    // If this is running at app startup, the pref being cleared
+    // will cause later stages of startup to notice that the
+    // old updates are now gone.
+    //
+    // Updates will only be explicitly uninstalled if they are
+    // removed restartlessly, for instance if they are no longer
+    // part of the latest update set.
     if (this._addonSet) {
-      logger.info("Removing all system add-on upgrades.");
-
-      // remove everything from the pref first, if uninstall
-      // fails then at least they will not be re-activated on
-      // next restart.
-      this._saveAddonSet({ schema: 1, addons: {} });
-
       for (let id of Object.keys(this._addonSet.addons)) {
         AddonManager.getAddonByID(id, addon => {
           if (addon) {
             addon.uninstall();
           }
         });
       }
     }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
@@ -354,16 +354,20 @@ add_task(function* test_bad_profile_cert
 });
 
 // Switching to app defaults that contain a bad certificate should still work
 add_task(function* test_bad_app_cert() {
   gAppInfo.version = "3";
   distroDir.leafName = "app3";
   startupManager();
 
+  // Since we updated the app version, the system addon set should be reset as well.
+  let addonSet = Services.prefs.getCharPref(PREF_SYSTEM_ADDON_SET);
+  do_check_eq(addonSet, `{"schema":1,"addons":{}}`);
+
   // Add-on will still be present
   let addon = yield promiseAddonByID("system1@tests.mozilla.org");
   do_check_neq(addon, null);
   do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_NOT_REQUIRED);
 
   let conditions = [
       { isUpgrade: false, version: "1.0" },
       { isUpgrade: false, version: null },
@@ -408,8 +412,9 @@ add_task(function* test_updated() {
   let conditions = [
       { isUpgrade: false, version: "1.0" },
   ];
 
   yield check_installed(conditions);
 
   yield promiseShutdownManager();
 });
+