Bug 564030: Updating an add-on that is incompatible to a version that is compatible requires more restarts. r=robstrong

This commit is contained in:
Dave Townsend 2010-05-06 12:45:56 -07:00
parent bc100d717d
commit 253ae29fe0
2 changed files with 72 additions and 5 deletions

View File

@ -2320,7 +2320,7 @@ var XPIDatabase = {
":maxVersion)",
clearVisibleAddons: "UPDATE addon SET visible=0 WHERE id=:id",
deactivateThemes: "UPDATE addon SET active=:active WHERE " +
updateAddonActive: "UPDATE addon SET active=:active WHERE " +
"internal_id=:internal_id",
getActiveAddons: "SELECT " + FIELDS_ADDON + " FROM addon WHERE active=1 AND " +
@ -3079,6 +3079,9 @@ var XPIDatabase = {
return row;
}
aAddon.active = (aAddon.visible && !aAddon.userDisabled &&
!aAddon.appDisabled);
if (aAddon.visible) {
let stmt = this.getStatement("clearVisibleAddons");
stmt.params.id = aAddon.id;
@ -3097,8 +3100,7 @@ var XPIDatabase = {
"bootstrap"].forEach(function(aProp) {
stmt.params[aProp] = aAddon[aProp] ? 1 : 0;
});
stmt.params.active = (aAddon.visible && !aAddon.userDisabled &&
!aAddon.appDisabled) ? 1 : 0;
stmt.params.active = aAddon.active ? 1 : 0;
stmt.execute();
let internal_id = this.connection.lastInsertRowID;
@ -3236,7 +3238,7 @@ var XPIDatabase = {
updateAddonActive: function XPIDB_updateAddonActive(aAddon) {
LOG("Updating add-on state");
stmt = this.getStatement("deactivateThemes");
stmt = this.getStatement("updateAddonActive");
stmt.params.internal_id = aAddon._internal_id;
stmt.params.active = aAddon.active ? 1 : 0;
stmt.execute();

View File

@ -0,0 +1,65 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests that upgrading an incompatible add-on to a compatible one forces an
// EM restart
const profileDir = gProfD.clone();
profileDir.append("extensions");
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "1.9.2");
dest = profileDir.clone();
dest.append("addon1@tests.mozilla.org");
writeInstallRDFToDir({
id: "addon1@tests.mozilla.org",
version: "1.0",
name: "Test",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}]
}, dest);
// Attempt to make this look like it was added some time in the past so
// the update makes the last modified time change.
dest.lastModifiedTime -= 5000;
startupManager(1);
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a) {
do_check_neq(a, null);
do_check_eq(a.version, "1.0");
do_check_false(a.userDisabled);
do_check_true(a.appDisabled);
do_check_false(a.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a.id));
writeInstallRDFToDir({
id: "addon1@tests.mozilla.org",
version: "2.0",
name: "Test",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "2"
}]
}, dest);
restartManager(1);
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a) {
do_check_neq(a, null);
do_check_eq(a.version, "2.0");
do_check_false(a.userDisabled);
do_check_false(a.appDisabled);
do_check_true(a.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a.id));
do_test_finished();
});
});
}