diff --git a/browser/components/enterprisepolicies/Policies.jsm b/browser/components/enterprisepolicies/Policies.jsm index ffc8185f6b6c..0c44db7aafd6 100644 --- a/browser/components/enterprisepolicies/Policies.jsm +++ b/browser/components/enterprisepolicies/Policies.jsm @@ -35,6 +35,12 @@ this.Policies = { } } }, + + "dont_check_default_browser": { + onBeforeUIStartup(manager, param) { + setAndLockPref("browser.shell.checkDefaultBrowser", false); + } + } }; /* diff --git a/browser/components/enterprisepolicies/schemas/policies-schema.json b/browser/components/enterprisepolicies/schemas/policies-schema.json index c0257dd93fd6..53105817ffb6 100644 --- a/browser/components/enterprisepolicies/schemas/policies-schema.json +++ b/browser/components/enterprisepolicies/schemas/policies-schema.json @@ -6,6 +6,14 @@ "description": "Blocks access to the about:config page.", "first_available": "60.0", + "type": "boolean", + "enum": [true] + }, + + "dont_check_default_browser": { + "description": "Don't check for the default browser on startup.", + "first_available": "60.0", + "type": "boolean", "enum": [true] } diff --git a/browser/components/enterprisepolicies/tests/browser/browser.ini b/browser/components/enterprisepolicies/tests/browser/browser.ini index 609611f5f1fb..f7c046594356 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser.ini +++ b/browser/components/enterprisepolicies/tests/browser/browser.ini @@ -3,6 +3,7 @@ prefs = browser.policies.enabled=true support-files = head.js + config_dont_check_default_browser.json config_setAndLockPref.json config_simple_policies.json config_broken_json.json @@ -11,3 +12,4 @@ support-files = [browser_policies_setAndLockPref_API.js] [browser_policies_simple_policies.js] [browser_policies_validate_and_parse_API.js] +[browser_policy_default_browser_check.js] diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_default_browser_check.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_default_browser_check.js new file mode 100644 index 000000000000..9d8a2d67ecb6 --- /dev/null +++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_default_browser_check.js @@ -0,0 +1,24 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; +const { ShellService } = Cu.import("resource:///modules/ShellService.jsm", {}); + +add_task(async function test_default_browser_check() { + ShellService._checkedThisSession = false; + // On a normal profile, the default is true. However, this gets set to false on the + // testing profile. Let's start with true for a sanity check. + + ShellService.shouldCheckDefaultBrowser = true; + is(ShellService.shouldCheckDefaultBrowser, true, "Sanity check"); + + await setupPolicyEngineWithJson("config_dont_check_default_browser.json"); + + is(ShellService.shouldCheckDefaultBrowser, false, "Policy changed it to not check"); + + // Try to change it to true and check that it doesn't take effect + ShellService.shouldCheckDefaultBrowser = true; + + is(ShellService.shouldCheckDefaultBrowser, false, "Policy is enforced"); +}); diff --git a/browser/components/enterprisepolicies/tests/browser/config_dont_check_default_browser.json b/browser/components/enterprisepolicies/tests/browser/config_dont_check_default_browser.json new file mode 100644 index 000000000000..ef049be71609 --- /dev/null +++ b/browser/components/enterprisepolicies/tests/browser/config_dont_check_default_browser.json @@ -0,0 +1,5 @@ +{ + "policies": { + "dont_check_default_browser": true + } +}