Commit 18ecbec5 authored by Julian Descottes's avatar Julian Descottes
Browse files

Bug 1429185 - Implement policy for disabling devtools;r=Felipe

MozReview-Commit-ID: D6ZvP7vWg4O

--HG--
extra : rebase_source : 78f5b5caa90c4586266b8a086344c7bce1544e74
parent 611ba35e
......@@ -125,6 +125,20 @@ var Policies = {
}
},
"DisableDeveloperTools": {
onBeforeAddons(manager, param) {
if (param) {
setAndLockPref("devtools.policy.disabled", true);
setAndLockPref("devtools.chrome.enabled", false);
manager.disallowFeature("devtools");
manager.disallowFeature("about:devtools");
manager.disallowFeature("about:debugging");
manager.disallowFeature("about:devtools-toolbox");
}
}
},
"DisableFirefoxScreenshots": {
onBeforeAddons(manager, param) {
if (param) {
......
......@@ -114,6 +114,13 @@
"enum": [true]
},
"DisableDeveloperTools": {
"description": "Prevents access to developer tools.",
"first_available": "60.0",
"type": "boolean"
},
"DisableFirefoxScreenshots": {
"description": "Prevents usage of the Firefox Screenshots feature.",
"first_available": "60.0",
......
[DEFAULT]
prefs =
browser.policies.enabled=true
browser.policies.alternatePath='<test-root>/browser/components/enterprisepolicies/tests/browser/disable_developer_tools/config_disable_developer_tools.json'
support-files =
config_disable_developer_tools.json
[browser_policy_disable_developer_tools.js]
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var updateService = Cc["@mozilla.org/updates/update-service;1"].
getService(Ci.nsIApplicationUpdateService);
add_task(async function test_updates_post_policy() {
is(Services.policies.isAllowed("devtools"), false,
"devtools should be disabled by policy.");
is(Services.prefs.getBoolPref("devtools.policy.disabled"), true,
"devtools dedicated disabled pref is set to true");
Services.prefs.setBoolPref("devtools.policy.disabled", false);
is(Services.prefs.getBoolPref("devtools.policy.disabled"), true,
"devtools dedicated disabled pref can not be updated");
await expectErrorPage("about:devtools");
await expectErrorPage("about:devtools-toolbox");
await expectErrorPage("about:debugging");
let testURL = "data:text/html;charset=utf-8,test";
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, testURL, false);
info("Check that devtools menu items are hidden");
let toolsMenu = window.document.getElementById("webDeveloperMenu");
ok(toolsMenu.hidden, "The Web Developer item of the tools menu is hidden");
let hamburgerMenu = window.document.getElementById("appMenu-developer-button");
ok(hamburgerMenu.hidden, "The Web Developer item of the hamburger menu is hidden");
await BrowserTestUtils.removeTab(tab);
});
const expectErrorPage = async function(url) {
info(`Wait for ${url} to open the net error page`);
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url, false);
await ContentTask.spawn(tab.linkedBrowser, null, async function() {
ok(content.document.documentURI.startsWith("about:neterror"),
"DevTools about: page should display the net error page");
});
await BrowserTestUtils.removeTab(tab);
};
......@@ -9,5 +9,6 @@ with Files("**"):
BROWSER_CHROME_MANIFESTS += [
'browser/browser.ini',
'browser/disable_app_update/browser.ini'
'browser/disable_app_update/browser.ini',
'browser/disable_developer_tools/browser.ini',
]
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