Bug 1245376 - do not advertise updates for locked install locations r?mossop
MozReview-Commit-ID: EmCzFZpOGKR
--- 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();
+});