Commit d07bae0b authored by Kirk Steuber's avatar Kirk Steuber
Browse files

Bug 1429169 - Add enterprise policy to disable the popup blocker r=Felipe,jaws

MozReview-Commit-ID: 8UG9m3mMLA7

--HG--
extra : rebase_source : 5044b0753907120b16738b95ca7e33c4160adbce
parent 0186dfd2
......@@ -473,9 +473,19 @@ var Policies = {
}
},
"Popups": {
"PopupBlocking": {
onBeforeUIStartup(manager, param) {
addAllowDenyPermissions("popup", param.Allow, null);
if (param.Locked) {
let blockValue = true;
if (param.Default !== undefined && !param.Default) {
blockValue = false;
}
setAndLockPref("dom.disable_open_during_load", blockValue);
} else if (param.Default !== undefined) {
setDefaultPref("dom.disable_open_during_load", !!param.Default);
}
}
},
......
......@@ -350,7 +350,7 @@
"type": "boolean"
},
"Popups": {
"PopupBlocking": {
"description": "Allow or deny popup usage.",
"first_available": "60.0",
......@@ -361,6 +361,14 @@
"items": {
"type": "origin"
}
},
"Default": {
"type": "boolean"
},
"Locked": {
"type": "boolean"
}
}
},
......
......@@ -33,6 +33,7 @@ support-files =
[browser_policy_disable_masterpassword.js]
[browser_policy_disable_pdfjs.js]
[browser_policy_disable_pocket.js]
[browser_policy_disable_popup_blocker.js]
[browser_policy_disable_privatebrowsing.js]
[browser_policy_disable_safemode.js]
[browser_policy_disable_shield.js]
......
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function restore_prefs() {
Services.prefs.clearUserPref("dom.disable_open_during_load");
}
let ORIGINAL_PREF_VALUE = undefined;
add_task(async function setup() {
// It seems that this pref is given a special testing value for some reason.
// Unset that value for this test, but save the old value
if (Services.prefs.prefHasUserValue("dom.disable_open_during_load")) {
ORIGINAL_PREF_VALUE = Services.prefs.getBoolPref("dom.disable_open_during_load");
Services.prefs.clearUserPref("dom.disable_open_during_load");
}
});
registerCleanupFunction(async function cleanup_prefs() {
if (ORIGINAL_PREF_VALUE === undefined) {
Services.prefs.clearUserPref("dom.disable_open_during_load");
} else {
Services.prefs.setBoolPref("dom.disable_open_during_load", ORIGINAL_PREF_VALUE);
}
});
async function test_popup_blocker_disabled({disabled, locked}) {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:preferences");
// eslint-disable-next-line no-shadow
await ContentTask.spawn(tab.linkedBrowser, {disabled, locked}, async function({disabled, locked}) {
let checkbox = content.document.getElementById("popupPolicy");
is(checkbox.checked, !disabled,
"Checkbox checked state should match policy's Block status");
is(checkbox.disabled, locked,
"Checkbox disabled state should match policy's Locked status");
});
BrowserTestUtils.removeTab(tab);
is(Services.prefs.prefIsLocked("dom.disable_open_during_load"), locked,
"Flash pref lock state should match policy lock state");
}
add_task(async function test_initial_state() {
await test_popup_blocker_disabled({disabled: false, locked: false});
});
add_task(async function test_empty_policy() {
await setupPolicyEngineWithJson({
"policies": {
"PopupBlocking": {
}
}
});
await test_popup_blocker_disabled({disabled: false, locked: false});
restore_prefs();
});
add_task(async function test_block() {
await setupPolicyEngineWithJson({
"policies": {
"PopupBlocking": {
"Default": true
}
}
});
await test_popup_blocker_disabled({disabled: false, locked: false});
restore_prefs();
});
add_task(async function test_block_locked() {
await setupPolicyEngineWithJson({
"policies": {
"PopupBlocking": {
"Default": true,
"Locked": true
}
}
});
await test_popup_blocker_disabled({disabled: false, locked: true});
restore_prefs();
});
add_task(async function test_locked() {
await setupPolicyEngineWithJson({
"policies": {
"PopupBlocking": {
"Locked": true
}
}
});
await test_popup_blocker_disabled({disabled: false, locked: true});
restore_prefs();
});
add_task(async function test_disabled() {
await setupPolicyEngineWithJson({
"policies": {
"PopupBlocking": {
"Default": false
}
}
});
await test_popup_blocker_disabled({disabled: true, locked: false});
restore_prefs();
});
add_task(async function test_disabled_locked() {
await setupPolicyEngineWithJson({
"policies": {
"PopupBlocking": {
"Default": false,
"Locked": true
}
}
});
await test_popup_blocker_disabled({disabled: true, locked: true});
restore_prefs();
});
{
"policies": {
"Popups": {
"PopupBlocking": {
"Allow": [
"https://www.allow.com",
"https://www.pre-existing-deny.com"
......
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