Bug 1429151 - Policy: Disable Sync. r=markh
MozReview-Commit-ID: Eg6hg7GNMod
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -135,16 +135,24 @@ var Policies = {
manager.disallowFeature("devtools");
manager.disallowFeature("about:devtools");
manager.disallowFeature("about:debugging");
manager.disallowFeature("about:devtools-toolbox");
}
}
},
+ "DisableFirefoxAccounts": {
+ onBeforeAddons(manager, param) {
+ if (param) {
+ setAndLockPref("identity.fxaccounts.enabled", false);
+ }
+ }
+ },
+
"DisableFirefoxScreenshots": {
onBeforeAddons(manager, param) {
if (param) {
setAndLockPref("extensions.screenshots.disabled", true);
}
}
},
@@ -177,17 +185,16 @@ var Policies = {
if (param) {
manager.disallowFeature("privatebrowsing");
manager.disallowFeature("about:privatebrowsing", true);
setAndLockPref("browser.privatebrowsing.autostart", false);
}
}
},
-
"DisplayBookmarksToolbar": {
onBeforeUIStartup(manager, param) {
if (param) {
// This policy is meant to change the default behavior, not to force it.
// If this policy was alreay applied and the user chose to re-hide the
// bookmarks toolbar, do not show it again.
runOnce("displayBookmarksToolbar", () => {
gXulStore.setValue(BROWSER_DOCUMENT_URL, "PersonalToolbar", "collapsed", "false");
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -116,16 +116,23 @@
"DisableDeveloperTools": {
"description": "Prevents access to developer tools.",
"first_available": "60.0",
"type": "boolean"
},
+ "DisableFirefoxAccounts": {
+ "description": "Disables Firefox Account based services, including Sync.",
+ "first_available": "60.0",
+
+ "type": "boolean"
+ },
+
"DisableFirefoxScreenshots": {
"description": "Prevents usage of the Firefox Screenshots feature.",
"first_available": "60.0",
"type": "boolean",
"enum": [true]
},
--- a/browser/components/enterprisepolicies/tests/browser/browser.ini
+++ b/browser/components/enterprisepolicies/tests/browser/browser.ini
@@ -17,16 +17,17 @@ support-files =
[browser_policy_block_about_addons.js]
[browser_policy_block_about_config.js]
[browser_policy_block_about_profiles.js]
[browser_policy_block_about_support.js]
[browser_policy_block_set_desktop_background.js]
[browser_policy_bookmarks.js]
[browser_policy_default_browser_check.js]
[browser_policy_disable_formhistory.js]
+[browser_policy_disable_fxaccounts.js]
[browser_policy_disable_fxscreenshots.js]
[browser_policy_disable_masterpassword.js]
[browser_policy_disable_pocket.js]
[browser_policy_disable_privatebrowsing.js]
[browser_policy_disable_shield.js]
[browser_policy_display_bookmarks.js]
[browser_policy_display_menu.js]
[browser_policy_remember_passwords.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_fxaccounts.js
@@ -0,0 +1,23 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function test_policy_disable_fxaccounts() {
+ is(gSync.SYNC_ENABLED, true, "Sync is enabled before setting the policy.");
+
+ await setupPolicyEngineWithJson({
+ "policies": {
+ "DisableFirefoxAccounts": true
+ }
+ });
+
+ is(gSync.SYNC_ENABLED, false, "Sync is disabled after setting the policy.");
+
+ // Manually clean-up the change made by the policy engine.
+ // This is needed in case this test runs twice in a row
+ // (such as in test-verify), in order for the first check
+ // to pass again.
+ Services.prefs.unlockPref("identity.fxaccounts.enabled");
+ Services.prefs.getDefaultBranch("").setBoolPref("identity.fxaccounts.enabled", true);
+});