From 7bd4010fd3a11eb897f519c78fa5b5338236a3cd Mon Sep 17 00:00:00 2001 From: Dave Townsend Date: Tue, 6 Apr 2010 09:57:53 -0700 Subject: [PATCH] Bug 553090: Check for updated compatibility for local file installs. r=robstrong --- toolkit/mozapps/extensions/XPIProvider.jsm | 24 ++++++++-- .../extensions/test/xpcshell/test_install.js | 44 ++++++++++++++++++- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/toolkit/mozapps/extensions/XPIProvider.jsm b/toolkit/mozapps/extensions/XPIProvider.jsm index f190eeeab783..be27986564ad 100644 --- a/toolkit/mozapps/extensions/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/XPIProvider.jsm @@ -3111,11 +3111,27 @@ function AddonInstall(callback, installLocation, url, hash, name, type, iconURL, let self = this; XPIDatabase.getVisibleAddonForID(this.addon.id, function(addon) { self.existingAddon = addon; - XPIProvider.installs.push(self); - AddonManagerPrivate.callInstallListeners("onNewInstall", self.listeners, - self.wrapper); - callback(self); + if (!self.addon.isCompatible) { + // TODO Should we send some event here? + this.state = AddonManager.STATE_CHECKING; + new UpdateChecker(self.addon, { + onUpdateFinished: function(addon, status) { + XPIProvider.installs.push(self); + AddonManagerPrivate.callInstallListeners("onNewInstall", self.listeners, + self.wrapper); + + callback(self); + } + }, AddonManager.UPDATE_WHEN_ADDON_INSTALLED); + } + else { + XPIProvider.installs.push(self); + AddonManagerPrivate.callInstallListeners("onNewInstall", self.listeners, + self.wrapper); + + callback(self); + } }); } else { diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_install.js b/toolkit/mozapps/extensions/test/xpcshell/test_install.js index 7f84ba0b139b..450643b86a63 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_install.js @@ -372,8 +372,50 @@ function check_test_7() { a3.uninstall(); restartManager(0); - end_test(); + run_test_8(); }); }); }); } + +function run_test_8() { + AddonManager.addInstallListener(InstallListener); + AddonManager.addAddonListener(AddonListener); + + prepare_test({ }, [ + "onNewInstall" + ]); + + AddonManager.getInstallForFile(do_get_addon("test_install3"), function(install) { + do_check_true(install.addon.isCompatible); + + prepare_test({ + "addon3@tests.mozilla.org": [ + "onInstalling" + ] + }, [ + "onInstallStarted", + "onInstallEnded", + ], check_test_8); + install.install(); + }); +} + +function check_test_8() { + restartManager(1); + + AddonManager.getAddon("addon3@tests.mozilla.org", function(a3) { + do_check_neq(a3, null); + do_check_eq(a3.type, "extension"); + do_check_eq(a3.version, "1.0"); + do_check_eq(a3.name, "Real Test 4"); + do_check_true(a3.isActive); + do_check_false(a3.appDisabled); + do_check_true(isExtensionInAddonsList(profileDir, a3.id)); + do_check_true(do_get_addon("test_install3").exists()); + a3.uninstall(); + restartManager(0); + + end_test(); + }); +}