mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 553872: Add a PENDING_UPGRADE bit and provide access to the Addon instance that is pending. r=robstrong
This commit is contained in:
parent
6a66331b70
commit
8961f0ce26
@ -811,6 +811,7 @@ var AddonManager = {
|
||||
PENDING_UNINSTALL: 4,
|
||||
// Indicates that the Addon will be installed after the application restarts.
|
||||
PENDING_INSTALL: 8,
|
||||
PENDING_UPGRADE: 16,
|
||||
|
||||
// Constants for permissions in Addon.permissions.
|
||||
// Indicates that the Addon can be uninstalled.
|
||||
|
@ -3610,6 +3610,10 @@ AddonInstall.prototype = {
|
||||
|
||||
LOG("Install of " + this.sourceURL.spec + " completed.");
|
||||
this.state = AddonManager.STATE_INSTALLED;
|
||||
if (isUpgrade) {
|
||||
delete this.existingAddon.pendingUpgrade;
|
||||
this.existingAddon.pendingUpgrade = this.addon;
|
||||
}
|
||||
AddonManagerPrivate.callInstallListeners("onInstallEnded",
|
||||
this.listeners, this.wrapper,
|
||||
createWrapper(this.addon));
|
||||
@ -3978,6 +3982,19 @@ function DBAddonInternal() {
|
||||
delete this.defaultLocale;
|
||||
return this.defaultLocale = XPIDatabase._getDefaultLocale(this);
|
||||
});
|
||||
|
||||
this.__defineGetter__("pendingUpgrade", function() {
|
||||
delete this.pendingUpgrade;
|
||||
for (let i = 0; i < XPIProvider.installs.length; i++) {
|
||||
let install = XPIProvider.installs[i];
|
||||
if (install.state == AddonManager.STATE_INSTALLED &&
|
||||
!(install.addon instanceof DBAddonInternal) &&
|
||||
install.addon.id == this.id &&
|
||||
install.installLocation == this._installLocation) {
|
||||
return this.pendingUpgrade = install.addon;
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
DBAddonInternal.prototype = {
|
||||
@ -4055,6 +4072,10 @@ function AddonWrapper(addon) {
|
||||
addon.updateAutomatically = val;
|
||||
});
|
||||
|
||||
this.__defineGetter__("pendingUpgrade", function() {
|
||||
return createWrapper(addon.pendingUpgrade);
|
||||
});
|
||||
|
||||
this.__defineGetter__("pendingOperations", function() {
|
||||
let pending = 0;
|
||||
if (!(addon instanceof DBAddonInternal))
|
||||
@ -4067,6 +4088,9 @@ function AddonWrapper(addon) {
|
||||
else if (!addon.active && (!addon.userDisabled && !addon.appDisabled))
|
||||
pending |= AddonManager.PENDING_ENABLE;
|
||||
|
||||
if (addon.pendingUpgrade)
|
||||
pending |= AddonManager.PENDING_UPGRADE;
|
||||
|
||||
return pending;
|
||||
});
|
||||
|
||||
|
@ -282,28 +282,34 @@ function check_test_5() {
|
||||
ensure_test_completed();
|
||||
AddonManager.getAddon("addon2@tests.mozilla.org", function(olda2) {
|
||||
do_check_neq(olda2, null);
|
||||
restartManager();
|
||||
do_check_true(hasFlag(olda2.pendingOperations, AddonManager.PENDING_UPGRADE));
|
||||
|
||||
AddonManager.getInstalls(null, function(installs) {
|
||||
do_check_eq(installs, 0);
|
||||
do_check_eq(installs.length, 1);
|
||||
do_check_eq(installs[0].addon, olda2.pendingUpgrade);
|
||||
restartManager();
|
||||
|
||||
AddonManager.getAddon("addon2@tests.mozilla.org", function(a2) {
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.type, "extension");
|
||||
do_check_eq(a2.version, "3.0");
|
||||
do_check_eq(a2.name, "Real Test 3");
|
||||
do_check_true(a2.isActive);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_true(do_get_addon("test_install2_2").exists());
|
||||
AddonManager.getInstalls(null, function(installs) {
|
||||
do_check_eq(installs.length, 0);
|
||||
|
||||
do_check_eq(a2.installDate.getTime(), gInstallDate);
|
||||
// Update date should be later (or the same if this test is too fast)
|
||||
do_check_true(a2.installDate <= a2.updateDate);
|
||||
AddonManager.getAddon("addon2@tests.mozilla.org", function(a2) {
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.type, "extension");
|
||||
do_check_eq(a2.version, "3.0");
|
||||
do_check_eq(a2.name, "Real Test 3");
|
||||
do_check_true(a2.isActive);
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_true(do_get_addon("test_install2_2").exists());
|
||||
|
||||
a2.uninstall();
|
||||
restartManager(0);
|
||||
do_check_eq(a2.installDate.getTime(), gInstallDate);
|
||||
// Update date should be later (or the same if this test is too fast)
|
||||
do_check_true(a2.installDate <= a2.updateDate);
|
||||
|
||||
run_test_6();
|
||||
a2.uninstall();
|
||||
restartManager(0);
|
||||
|
||||
run_test_6();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user