forked from mirrors/gecko-dev
Bug 1429169 - Add enterprise policy for disabling the Flash plugin r=Felipe,jaws
MozReview-Commit-ID: AEZZbaYwTLT --HG-- extra : rebase_source : 703753499841f78eca92269bbc540b3dafdb69d4
This commit is contained in:
parent
964d5cd4bc
commit
1897099cd9
4 changed files with 161 additions and 0 deletions
|
|
@ -391,6 +391,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]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,134 @@
|
|||
/* 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();
|
||||
});
|
||||
Loading…
Reference in a new issue