Bug 1249074: Don't offer existing sideloaded add-ons to users when creating a new profile. r?rhelmer draft
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 17 Feb 2016 11:06:00 -0800
changeset 331670 80925d0fd2d73fcf0b2d3cdfda7da61f0948ca07
parent 331539 15621f98b53b1994c7ae2e2703a6e50203c5304c
child 514422 0a8b2c98012c239f8c6cc09fbefe2df3d1fa43c8
push id11027
push userdtownsend@mozilla.com
push dateWed, 17 Feb 2016 20:15:57 +0000
reviewersrhelmer
bugs1249074
milestone47.0a1
Bug 1249074: Don't offer existing sideloaded add-ons to users when creating a new profile. r?rhelmer MozReview-Commit-ID: 7pnZhEvGRfj
toolkit/mozapps/extensions/internal/XPIProviderUtils.js
toolkit/mozapps/extensions/test/xpcshell/test_seen_newprofile.js
toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
--- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
+++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
@@ -1711,17 +1711,20 @@ this.XPIDatabaseReconcile = {
     if (isDetectedInstall && aNewAddon.foreignInstall) {
       // If the add-on is a foreign install and is in a scope where add-ons
       // that were dropped in should default to disabled then disable it
       let disablingScopes = Preferences.get(PREF_EM_AUTO_DISABLED_SCOPES, 0);
       if (aInstallLocation.scope & disablingScopes) {
         logger.warn("Disabling foreign installed add-on " + aNewAddon.id + " in "
             + aInstallLocation.name);
         aNewAddon.userDisabled = true;
-        aNewAddon.seen = false;
+
+        // If we don't have an old app version then this is a new profile in
+        // which case just mark any sideloaded add-ons as already seen.
+        aNewAddon.seen = !aOldAppVersion;
       }
     }
 
     return XPIDatabase.addAddonMetadata(aNewAddon, aAddonState.descriptor);
   },
 
   /**
    * Called when an add-on has been removed.
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_seen_newprofile.js
@@ -0,0 +1,41 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+const ID = "bootstrap1@tests.mozilla.org";
+
+Services.prefs.setIntPref("extensions.enabledScopes",
+                          AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_SYSTEM);
+
+createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
+
+BootstrapMonitor.init();
+
+const globalDir = gProfD.clone();
+globalDir.append("extensions2");
+globalDir.append(gAppInfo.ID);
+registerDirectory("XRESysSExtPD", globalDir.parent);
+const profileDir = gProfD.clone();
+profileDir.append("extensions");
+
+// By default disable add-ons from the system
+Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_SYSTEM);
+
+// When new add-ons already exist in a system location when starting with a new
+// profile they should be marked as already seen.
+add_task(function*() {
+  manuallyInstall(do_get_addon("test_bootstrap1_1"), globalDir, ID);
+
+  startupManager();
+
+  let addon = yield promiseAddonByID(ID);
+  do_check_true(addon.foreignInstall);
+  do_check_true(addon.seen);
+  do_check_true(addon.userDisabled);
+  do_check_false(addon.isActive);
+
+  BootstrapMonitor.checkAddonInstalled(ID);
+  BootstrapMonitor.checkAddonNotStarted(ID);
+
+  yield promiseShutdownManager();
+});
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
@@ -278,16 +278,17 @@ skip-if = os == "android"
 # Bug 676992: test consistently hangs on Android
 skip-if = os == "android"
 [test_updatecheck.js]
 # Bug 676992: test consistently hangs on Android
 skip-if = os == "android"
 run-sequentially = Uses hardcoded ports in xpi files.
 [test_json_updatecheck.js]
 [test_seen.js]
+[test_seen_newprofile.js]
 [test_updateid.js]
 # Bug 676992: test consistently hangs on Android
 skip-if = os == "android"
 run-sequentially = Uses hardcoded ports in xpi files.
 [test_update_compatmode.js]
 [test_upgrade.js]
 # Bug 676992: test consistently hangs on Android
 skip-if = os == "android"
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
@@ -27,9 +27,10 @@ skip-if = appname != "firefox"
 [test_shutdown.js]
 [test_system_update.js]
 [test_system_reset.js]
 [test_XPIcancel.js]
 [test_XPIStates.js]
 [test_temporary.js]
 [test_proxy.js]
 
+
 [include:xpcshell-shared.ini]