Commit 0186dfd2 authored by Kirk Steuber's avatar Kirk Steuber
Browse files

Bug 1429169 - Add enterprise policy for disabling the Flash plugin r=Felipe,jaws

MozReview-Commit-ID: AEZZbaYwTLT

--HG--
extra : rebase_source : c46c1d7c0f9671d9c42e30895896f895159d39ea
parent 058dddac
......@@ -408,6 +408,24 @@ var Policies = {
"FlashPlugin": {
onBeforeUIStartup(manager, param) {
addAllowDenyPermissions("plugin:flash", param.Allow, param.Block);
const FLASH_NEVER_ACTIVATE = 0;
const FLASH_ASK_TO_ACTIVATE = 1;
const FLASH_ALWAYS_ACTIVATE = 2;
let flashPrefVal;
if (param.Default === undefined) {
flashPrefVal = FLASH_ASK_TO_ACTIVATE;
} else if (param.Default) {
flashPrefVal = FLASH_ALWAYS_ACTIVATE;
} else {
flashPrefVal = FLASH_NEVER_ACTIVATE;
}
if (param.Locked) {
setAndLockPref("plugin.state.flash", flashPrefVal);
} else if (param.Default !== undefined) {
setDefaultPref("plugin.state.flash", flashPrefVal);
}
}
},
......
......@@ -293,6 +293,14 @@
"items": {
"type": "origin"
}
},
"Default": {
"type": "boolean"
},
"Locked": {
"type": "boolean"
}
}
},
......
......@@ -28,6 +28,7 @@ support-files =
[browser_policy_cookie_settings.js]
[browser_policy_default_browser_check.js]
[browser_policy_disable_feedback_commands.js]
[browser_policy_disable_flash_plugin.js]
[browser_policy_disable_fxaccounts.js]
[browser_policy_disable_masterpassword.js]
[browser_policy_disable_pdfjs.js]
......
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const labelTextAlwaysActivate = "Always Activate";
const labelTextAskToActivate = "Ask to Activate";
const labelTextNeverActivate = "Never Activate";
function restore_prefs() {
Services.prefs.clearUserPref("plugin.state.flash");
}
registerCleanupFunction(restore_prefs);
async function test_flash_status({expectedLabelText, locked}) {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
await BrowserOpenAddonsMgr("addons://list/plugin");
await ContentTask.spawn(tab.linkedBrowser, {aExpectedLabelText: expectedLabelText, aLocked: locked}, async function({aExpectedLabelText, aLocked}) {
let list = content.document.getElementById("addon-list");
let flashEntry = list.getElementsByAttribute("name", "Shockwave Flash")[0];
let dropDown = content.document.getAnonymousElementByAttribute(flashEntry, "anonid", "state-menulist");
is(dropDown.label, aExpectedLabelText,
"Flash setting text should match the expected value");
is(dropDown.disabled, aLocked,
"Flash controls disabled state should match policy locked state");
});
BrowserTestUtils.removeTab(tab);
is(Services.prefs.prefIsLocked("plugin.state.flash"), locked,
"Flash pref lock state should match policy lock state");
}
add_task(async function test_enabled() {
await setupPolicyEngineWithJson({
"policies": {
"FlashPlugin": {
"Default": true
}
}
});
await test_flash_status({
expectedLabelText: labelTextAlwaysActivate,
locked: false
});
restore_prefs();
});
add_task(async function test_enabled_locked() {
await setupPolicyEngineWithJson({
"policies": {
"FlashPlugin": {
"Default": true,
"Locked": true
}
}
});
await test_flash_status({
expectedLabelText: labelTextAlwaysActivate,
locked: true
});
restore_prefs();
});
add_task(async function test_disabled() {
await setupPolicyEngineWithJson({
"policies": {
"FlashPlugin": {
"Default": false
}
}
});
await test_flash_status({
expectedLabelText: labelTextNeverActivate,
locked: false
});
restore_prefs();
});
add_task(async function test_disabled_locked() {
await setupPolicyEngineWithJson({
"policies": {
"FlashPlugin": {
"Default": false,
"Locked": true
}
}
});
await test_flash_status({
expectedLabelText: labelTextNeverActivate,
locked: true
});
restore_prefs();
});
add_task(async function test_ask() {
await setupPolicyEngineWithJson({
"policies": {
"FlashPlugin": {
}
}
});
await test_flash_status({
expectedLabelText: labelTextAskToActivate,
locked: false
});
restore_prefs();
});
add_task(async function test_ask_locked() {
await setupPolicyEngineWithJson({
"policies": {
"FlashPlugin": {
"Locked": true
}
}
});
await test_flash_status({
expectedLabelText: labelTextAskToActivate,
locked: true
});
restore_prefs();
});
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