Bug 1429141 - Policy: Don't check if Firefox is the default browser on startup. r=Gijs
MozReview-Commit-ID: CBnKl2F5PVI
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -72,16 +72,22 @@ this.Policies = {
}
},
"cookies": {
onBeforeUIStartup(manager, param) {
addAllowDenyPermissions("cookie", param.allow, param.block);
}
},
+
+ "dont_check_default_browser": {
+ onBeforeUIStartup(manager, param) {
+ setAndLockPref("browser.shell.checkDefaultBrowser", false);
+ }
+ }
};
/*
* ====================
* = HELPER FUNCTIONS =
* ====================
*
* The functions below are helpers to be used by several policies.
--- a/browser/components/enterprisepolicies/schemas/policies.json
+++ b/browser/components/enterprisepolicies/schemas/policies.json
@@ -110,11 +110,19 @@
"block": {
"type": "array",
"items": {
"type": "origin"
}
}
}
+ },
+
+ "dont_check_default_browser": {
+ "description": "Don't check for the default browser on startup.",
+ "first_available": "60.0",
+
+ "type": "boolean",
+ "enum": [true]
}
}
}
--- a/browser/components/enterprisepolicies/tests/browser/browser.ini
+++ b/browser/components/enterprisepolicies/tests/browser/browser.ini
@@ -1,17 +1,19 @@
[DEFAULT]
prefs =
browser.policies.enabled=true
support-files =
head.js
config_block_about_config.json
+ config_dont_check_default_browser.json
config_popups_cookies_addons_flash.json
config_setAndLockPref.json
config_simple_policies.json
config_broken_json.json
[browser_policies_broken_json.js]
[browser_policies_popups_cookies_addons_flash.js]
[browser_policies_setAndLockPref_API.js]
[browser_policies_simple_policies.js]
[browser_policies_validate_and_parse_API.js]
[browser_policy_block_about_config.js]
+[browser_policy_default_browser_check.js]
new file mode 100644
--- /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";
+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");
+});
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/config_dont_check_default_browser.json
@@ -0,0 +1,5 @@
+{
+ "policies": {
+ "dont_check_default_browser": true
+ }
+}