Bug 562922: Multiple entries of the same extension and theme appear if the installation/update is triggered more than once. r=robstrong, a=blocks-betaN

This commit is contained in:
Dave Townsend 2010-10-18 13:51:46 -07:00
parent 8ae5556917
commit 4ce61ffa6c
3 changed files with 67 additions and 3 deletions

View File

@ -548,9 +548,8 @@ function test_renotify_installed() {
is(notification.id, "addon-install-complete-notification", "Should have seen the second install complete");
AddonManager.getAllInstalls(function(aInstalls) {
is(aInstalls.length, 2, "Should be two pending installs");
is(aInstalls.length, 1, "Should be one pending installs");
aInstalls[0].cancel();
aInstalls[1].cancel();
gBrowser.removeTab(gBrowser.selectedTab);
runNextTest();

View File

@ -5068,6 +5068,15 @@ AddonInstall.prototype = {
return;
}
// Find and cancel any pending installs for the same add-on in the same
// install location
XPIProvider.installs.forEach(function(aInstall) {
if (aInstall.state == AddonManager.STATE_INSTALLED &&
aInstall.installLocation == this.installLocation &&
aInstall.addon.id == this.addon.id)
aInstall.cancel();
}, this);
let isUpgrade = this.existingAddon &&
this.existingAddon._installLocation == this.installLocation;
let requiresRestart = XPIProvider.installRequiresRestart(this.addon);

View File

@ -1228,10 +1228,66 @@ function run_test_20() {
restartManager();
Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", false);
end_test();
run_test_21();
});
}
});
aInstall.install();
}, "application/x-xpinstall");
}
// Verify that installing an add-on that is already pending install cancels the
// first install
function run_test_21() {
installAllFiles([do_get_addon("test_install2_1")], function() {
AddonManager.getAllInstalls(function(aInstalls) {
do_check_eq(aInstalls.length, 1);
prepare_test({
"addon2@tests.mozilla.org": [
"onOperationCancelled",
"onInstalling"
]
}, [
"onNewInstall",
"onDownloadStarted",
"onDownloadEnded",
"onInstallStarted",
"onInstallCancelled",
"onInstallEnded",
], check_test_21);
let url = "http://localhost:4444/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.install();
}, "application/x-xpinstall");
});
});
}
function check_test_21(aInstall) {
AddonManager.getAllInstalls(function(aInstalls) {
do_check_eq(aInstalls.length, 1);
do_check_eq(aInstalls[0], aInstall);
prepare_test({
"addon2@tests.mozilla.org": [
"onOperationCancelled"
]
}, [
"onInstallCancelled",
]);
aInstall.cancel();
ensure_test_completed();
restartManager();
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_eq(a2, null);
end_test();
});
});
}