Bug 1245376 - do not advertise updates for locked install locations r?mossop draft
authorRobert Helmer <rhelmer@mozilla.com>
Mon, 29 Feb 2016 14:53:56 -0800
changeset 336171 363cb3d1b0ca08a7a555d23a55bb8edaa0fb90ea
parent 334896 ec700560eba22e7efcb4e263650bc5e88f65d4bf
child 515335 43f4b027bffea5ded4e4dcf730b924ee0bd5fac6
push id12003
push userrhelmer@mozilla.com
push dateWed, 02 Mar 2016 19:55:51 +0000
reviewersmossop
bugs1245376
milestone47.0a1
Bug 1245376 - do not advertise updates for locked install locations r?mossop MozReview-Commit-ID: EmCzFZpOGKR
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_update.js
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -6495,23 +6495,24 @@ UpdateChecker.prototype = {
                          AddonManager.UPDATE_STATUS_NO_ERROR);
     }
 
     let compatOverrides = AddonManager.strictCompatibility ?
                             null :
                             this.addon.compatibilityOverrides;
 
     let update = AUC.getNewestCompatibleUpdate(aUpdates,
-                                               this.appVersion,
-                                               this.platformVersion,
-                                               ignoreMaxVersion,
-                                               ignoreStrictCompat,
-                                               compatOverrides);
-
-    if (update && Services.vc.compare(this.addon.version, update.version) < 0) {
+                                           this.appVersion,
+                                           this.platformVersion,
+                                           ignoreMaxVersion,
+                                           ignoreStrictCompat,
+                                           compatOverrides);
+
+    if (update && Services.vc.compare(this.addon.version, update.version) < 0
+        && !this.addon._installLocation.locked) {
       for (let currentInstall of XPIProvider.installs) {
         // Skip installs that don't match the available update
         if (currentInstall.existingAddon != this.addon ||
             currentInstall.version != update.version)
           continue;
 
         // If the existing install has not yet started downloading then send an
         // available update notification. If it is already downloading then
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update.js
@@ -1347,8 +1347,52 @@ function check_test_7_cache() {
     do_check_eq(currentTheme.updateURL, "https://localhost:" + gPort + "/data/lwtheme.js?v=3");
 
     do_check_eq(p1.installDate.getTime(), gInstallDate);
     do_check_true(p1.installDate.getTime() < p1.updateDate.getTime());
 
     run_next_test();
   });
 }
+
+// Test that the update check returns nothing for addons in locked install
+// locations.
+add_test(function run_test_locked_install() {
+  const lockedDir = gProfD.clone();
+  lockedDir.append("locked_extensions");
+  registerDirectory("XREAppFeat", lockedDir);
+  restartManager();
+  writeInstallRDFForExtension({
+    id: "addon13@tests.mozilla.org",
+    version: "1.0",
+    updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+    targetApplications: [{
+      id: "xpcshell@tests.mozilla.org",
+      minVersion: "0.1",
+      maxVersion: "0.2"
+    }],
+    name: "Test Addon 13",
+  }, lockedDir);
+  restartManager();
+
+  AddonManager.getAddonByID("addon13@tests.mozilla.org", function(a13) {
+    do_check_neq(a13, null);
+
+    a13.findUpdates({
+      onCompatibilityUpdateAvailable: function() {
+        ok(false, "Should have not have seen compatibility information");
+      },
+
+      onUpdateAvailable: function() {
+        ok(false, "Should not have seen an available update");
+      },
+
+      onUpdateFinished: function() {
+        ok(true, "Should have seen an onUpdateFinished");
+      }
+    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+  });
+
+  AddonManager.getAllInstalls(aInstalls => {
+    do_check_eq(aInstalls.length, 0);
+  });
+  run_next_test();
+});