Bug 1350064 - test that updated system add-ons are reset on app update r?aswan
MozReview-Commit-ID: BbUtIMfCDXZ
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -8655,25 +8655,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();
});
+