Commit 07056aad authored by Michael Kaply's avatar Michael Kaply
Browse files

Bug 1433870 - Policy: Tracking protection. r=felipe,bytesized

parent 8de5d131
......@@ -263,6 +263,18 @@ var Policies = {
}
},
"EnableTrackingProtection": {
onBeforeUIStartup(manager, param) {
if (param.Locked) {
setAndLockPref("privacy.trackingprotection.enabled", param.Value);
setAndLockPref("privacy.trackingprotection.pbmode.enabled", param.Value);
} else {
setDefaultPref("privacy.trackingprotection.enabled", param.Value);
setDefaultPref("privacy.trackingprotection.pbmode.enabled", param.Value);
}
}
},
"FlashPlugin": {
onBeforeUIStartup(manager, param) {
addAllowDenyPermissions("plugin:flash", param.Allow, param.Block);
......@@ -338,6 +350,23 @@ function setAndLockPref(prefName, prefValue) {
Services.prefs.unlockPref(prefName);
}
setDefaultPref(prefName, prefValue);
Services.prefs.lockPref(prefName);
}
/**
* setDefaultPref
*
* Sets the _default_ value of a pref.
* The value is only changed in memory, and not stored to disk.
*
* @param {string} prefName
* The pref to be changed
* @param {boolean,number,string} prefValue
* The value to set
*/
function setDefaultPref(prefName, prefValue) {
let defaults = Services.prefs.getDefaultBranch("");
switch (typeof(prefValue)) {
......@@ -357,8 +386,6 @@ function setAndLockPref(prefName, prefValue) {
defaults.setStringPref(prefName, prefValue);
break;
}
Services.prefs.lockPref(prefName);
}
/**
......
......@@ -207,6 +207,22 @@
"type": "boolean"
},
"EnableTrackingProtection": {
"description": "Enables or disables tracking protection and optionally locks it.",
"first_available": "60.0",
"type": "object",
"properties": {
"Value": {
"type": "boolean"
},
"Locked": {
"type": "boolean"
}
},
"required": ["Value"]
},
"FlashPlugin": {
"description": "Allow or deny flash plugin usage.",
"first_available": "60.0",
......
......@@ -36,5 +36,6 @@ support-files =
[browser_policy_disable_shield.js]
[browser_policy_display_bookmarks.js]
[browser_policy_display_menu.js]
[browser_policy_enable_tracking_protection.js]
[browser_policy_remember_passwords.js]
[browser_policy_set_homepage.js]
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function test_policy_enable_tracking_protection1() {
await setupPolicyEngineWithJson({
"policies": {
"EnableTrackingProtection": {
"Value": true
}
}
});
is(Services.prefs.getBoolPref("privacy.trackingprotection.enabled"), true, "Tracking protection has been enabled by default.");
is(Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled"), true, "Tracking protection has been enabled by default in private browsing mode.");
is(Services.prefs.prefIsLocked("privacy.trackingprotection.enabled"), false, "Tracking protection pref is not locked.");
});
add_task(async function test_policy_enable_tracking_protection1() {
await setupPolicyEngineWithJson({
"policies": {
"EnableTrackingProtection": {
"Value": false,
"Locked": true
}
}
});
is(Services.prefs.getBoolPref("privacy.trackingprotection.enabled"), false, "Tracking protection has been disabled by default.");
is(Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled"), false, "Tracking protection has been disabled by default in private browsing mode.");
is(Services.prefs.prefIsLocked("privacy.trackingprotection.enabled"), true, "Tracking protection pref is locked.");
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment