Bug 553090: Check for updated compatibility for local file installs. r=robstrong
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 06 Apr 2010 09:57:53 -0700
changeset 41559 a40697759e2d56f8e3f89c4cf061005285ad286c
parent 41558 d44f759a97b42f78e7d358f8ab1724a61c226c93
child 41560 c597b774dc77d55fb5f15d8aff6c9dc3696717a6
push idunknown
push userunknown
push dateunknown
reviewersrobstrong
bugs553090
milestone1.9.3a5pre
Bug 553090: Check for updated compatibility for local file installs. r=robstrong
toolkit/mozapps/extensions/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_install.js
--- a/toolkit/mozapps/extensions/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/XPIProvider.jsm
@@ -3106,21 +3106,37 @@ function AddonInstall(callback, installL
     this.name = this.addon.selectedLocale.name;
     this.type = this.addon.type;
     this.version = this.addon.version;
     this.iconURL = this.addon.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 {
     this.state = AddonManager.STATE_AVAILABLE;
     this.name = name;
     this.type = type;
     this.version = version;
     this.iconURL = iconURL;
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_install.js
@@ -367,13 +367,55 @@ function check_test_7() {
         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();
+        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();
+  });
+}