Bug 596336: Allow modifying the userDisabled property of new installs. r=robstrong, a=blocks-betaN

This commit is contained in:
Dave Townsend 2010-10-11 14:37:16 -07:00
Родитель 06e04f6769
Коммит 9178d6f884
3 изменённых файлов: 221 добавлений и 3 удалений

Просмотреть файл

@ -1537,6 +1537,8 @@ var XPIProvider = {
newAddon = loadManifestFromZipFile(file);
else
newAddon = loadManifestFromDir(file);
// Carry over the userDisabled setting for add-ons that just appeared
newAddon.userDisabled = aOldAddon.userDisabled;
}
// The ID in the manifest that was loaded must match the ID of the old
@ -3936,7 +3938,6 @@ var XPIDatabase = {
// Any errors in here should rollback the transaction
try {
this.removeAddonMetadata(aOldAddon);
aNewAddon.userDisabled = aOldAddon.userDisabled;
aNewAddon.installDate = aOldAddon.installDate;
aNewAddon.applyBackgroundUpdates = aOldAddon.applyBackgroundUpdates;
this.addAddonMetadata(aNewAddon, aDescriptor);
@ -4218,6 +4219,8 @@ function AddonInstall(aCallback, aInstallLocation, aUrl, aHash, aName, aType,
this.loadManifest(function() {
XPIDatabase.getVisibleAddonForID(self.addon.id, function(aAddon) {
self.existingAddon = aAddon;
if (aAddon)
self.addon.userDisabled = aAddon.userDisabled;
self.addon.updateDate = Date.now();
self.addon.installDate = aAddon ? aAddon.installDate : self.addon.updateDate;
@ -4866,6 +4869,8 @@ AddonInstall.prototype = {
let self = this;
XPIDatabase.getVisibleAddonForID(this.addon.id, function(aAddon) {
self.existingAddon = aAddon;
if (aAddon)
self.addon.userDisabled = aAddon.userDisabled;
self.addon.updateDate = Date.now();
self.addon.installDate = aAddon ? aAddon.installDate : self.addon.updateDate;
self.state = AddonManager.STATE_DOWNLOADED;

Просмотреть файл

@ -637,8 +637,79 @@ function run_test_14() {
});
}
// Tests that bootstrapped extensions don't get loaded when in safe mode
// Tests that upgrading a disabled bootstrapped extension still calls uninstall
// and install but doesn't startup the new version
function run_test_15() {
installAllFiles([do_get_addon("test_bootstrap1_1")], function() {
AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
do_check_eq(getInstalledVersion(), 1);
do_check_eq(getActiveVersion(), 1);
b1.userDisabled = true;
do_check_false(b1.isActive);
do_check_eq(getInstalledVersion(), 1);
do_check_eq(getActiveVersion(), 0);
prepare_test({ }, [
"onNewInstall"
]);
AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_2"), function(install) {
ensure_test_completed();
do_check_neq(install, null);
do_check_true(install.addon.userDisabled);
prepare_test({
"bootstrap1@tests.mozilla.org": [
["onInstalling", false],
"onInstalled"
]
}, [
"onInstallStarted",
"onInstallEnded",
], check_test_15);
install.install();
});
});
});
}
function check_test_15() {
AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "2.0");
do_check_false(b1.appDisabled);
do_check_true(b1.userDisabled);
do_check_false(b1.isActive);
do_check_eq(getInstalledVersion(), 2);
do_check_eq(getActiveVersion(), 0);
restartManager();
AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "2.0");
do_check_false(b1.appDisabled);
do_check_true(b1.userDisabled);
do_check_false(b1.isActive);
do_check_eq(getInstalledVersion(), 2);
do_check_eq(getActiveVersion(), 0);
b1.uninstall();
run_test_16();
});
});
}
// Tests that bootstrapped extensions don't get loaded when in safe mode
function run_test_16() {
installAllFiles([do_get_addon("test_bootstrap1_1")], function() {
AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
// Should have installed and started

Просмотреть файл

@ -947,7 +947,149 @@ function check_test_13(install) {
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_eq(a2.version, "2.0");
end_test();
a2.uninstall();
restartManager();
run_test_14();
});
});
}
// Verify that the userDisabled value carries over to the upgrade by default
function run_test_14() {
let url = "http://localhost:4444/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
onInstallStarted: function() {
do_check_false(aInstall.addon.userDisabled);
aInstall.addon.userDisabled = true;
},
onInstallEnded: function() {
restartManager();
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
let url = "http://localhost:4444/addons/test_install2_2.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
onInstallEnded: function() {
do_check_true(aInstall.addon.userDisabled);
restartManager();
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
a2.uninstall();
restartManager();
run_test_15();
});
}
});
aInstall.install();
}, "application/x-xpinstall");
});
}
});
aInstall.install();
}, "application/x-xpinstall");
}
// Verify that changing the userDisabled value before onInstallEnded works
function run_test_15() {
let url = "http://localhost:4444/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
onInstallEnded: function() {
do_check_false(aInstall.addon.userDisabled);
restartManager();
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_false(a2.userDisabled);
do_check_true(a2.isActive);
let url = "http://localhost:4444/addons/test_install2_2.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
onInstallStarted: function() {
do_check_false(aInstall.addon.userDisabled);
aInstall.addon.userDisabled = true;
},
onInstallEnded: function() {
restartManager();
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
a2.uninstall();
restartManager();
run_test_16();
});
}
});
aInstall.install();
}, "application/x-xpinstall");
});
}
});
aInstall.install();
}, "application/x-xpinstall");
}
// Verify that changing the userDisabled value before onInstallEnded works
function run_test_16() {
let url = "http://localhost:4444/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
onInstallStarted: function() {
do_check_false(aInstall.addon.userDisabled);
aInstall.addon.userDisabled = true;
},
onInstallEnded: function() {
restartManager();
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
let url = "http://localhost:4444/addons/test_install2_2.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
onInstallStarted: function() {
do_check_true(aInstall.addon.userDisabled);
aInstall.addon.userDisabled = false;
},
onInstallEnded: function() {
restartManager();
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_false(a2.userDisabled);
do_check_true(a2.isActive);
a2.uninstall();
restartManager();
end_test();
});
}
});
aInstall.install();
}, "application/x-xpinstall");
});
}
});
aInstall.install();
}, "application/x-xpinstall");
}