diff --git a/browser/extensions/shield-recipe-client/lib/ShieldRecipeClient.jsm b/browser/extensions/shield-recipe-client/lib/ShieldRecipeClient.jsm index 7498b8e1d2c2..ff3392a4fec1 100644 --- a/browser/extensions/shield-recipe-client/lib/ShieldRecipeClient.jsm +++ b/browser/extensions/shield-recipe-client/lib/ShieldRecipeClient.jsm @@ -42,6 +42,7 @@ const DEFAULT_PREFS = { first_run: true, }; const PREF_DEV_MODE = "extensions.shield-recipe-client.dev_mode"; +const PREF_SELF_SUPPORT_ENABLED = "browser.selfsupport.enabled"; const PREF_LOGGING_LEVEL = PREF_BRANCH + "logging.level"; let log = null; @@ -63,6 +64,16 @@ this.ShieldRecipeClient = { ); log = LogManager.getLogger("bootstrap"); + // Disable self-support, since we replace its behavior. + // Self-support only checks its pref on start, so if we disable it, wait + // until next startup to run, unless the dev_mode preference is set. + if (Preferences.get(PREF_SELF_SUPPORT_ENABLED, true)) { + Preferences.set(PREF_SELF_SUPPORT_ENABLED, false); + if (!Preferences.get(PREF_DEV_MODE, false)) { + return; + } + } + // Initialize experiments first to avoid a race between initializing prefs // and recipes rolling back pref changes when experiments end. try { @@ -76,6 +87,11 @@ this.ShieldRecipeClient = { shutdown(reason) { CleanupManager.cleanup(); + + // Re-enable self-support if we're being disabled. + if (reason === REASONS.ADDON_DISABLE || reason === REASONS.ADDON_UNINSTALL) { + Services.prefs.setBoolPref(PREF_SELF_SUPPORT_ENABLED, true); + } }, setDefaultPrefs() { diff --git a/browser/extensions/shield-recipe-client/test/browser/browser_ClientEnvironment.js b/browser/extensions/shield-recipe-client/test/browser/browser_ClientEnvironment.js index a831afb4c45f..21ddd4381abe 100644 --- a/browser/extensions/shield-recipe-client/test/browser/browser_ClientEnvironment.js +++ b/browser/extensions/shield-recipe-client/test/browser/browser_ClientEnvironment.js @@ -116,9 +116,6 @@ add_task(async function testExperiments() { add_task(async function isFirstRun() { let environment = ClientEnvironment.getEnvironment(); - // isFirstRun is set to false after the recipe client runs - ok(!environment.isFirstRun, "isFirstRun has a default value"); - // isFirstRun is read from a preference await SpecialPowers.pushPrefEnv({set: [["extensions.shield-recipe-client.first_run", true]]}); environment = ClientEnvironment.getEnvironment(); diff --git a/testing/profiles/prefs_general.js b/testing/profiles/prefs_general.js index bf2f780b701e..9059e0759e1e 100644 --- a/testing/profiles/prefs_general.js +++ b/testing/profiles/prefs_general.js @@ -321,7 +321,7 @@ user_pref("browser.search.countryCode", "US"); user_pref("browser.search.geoSpecificDefaults", false); // Make sure Shield doesn't hit the network. -user_pref("extensions.shield-recipe-client.api_url", "https://%(server)s/selfsupport-dummy/"); +user_pref("extensions.shield-recipe-client.api_url", "https://example.com/selfsupport-dummy/"); user_pref("media.eme.enabled", true);