Bug 1429123 - Create an enterprise policy to prevent access to the Add-ons manager (about:addons)
MozReview-Commit-ID: KslHBo0kvvu
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -24,16 +24,24 @@ XPCOMUtils.defineLazyGetter(this, "log",
maxLogLevel: "error",
maxLogLevelPref: PREF_LOGLEVEL,
});
});
this.EXPORTED_SYMBOLS = ["Policies"];
this.Policies = {
+ "BlockAboutAddons": {
+ onBeforeUIStartup(manager, param) {
+ if (param) {
+ manager.disallowFeature("about:addons", true);
+ }
+ }
+ },
+
"BlockAboutConfig": {
onBeforeUIStartup(manager, param) {
if (param) {
manager.disallowFeature("about:config", true);
}
}
},
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -1,12 +1,20 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
+ "BlockAboutAddons": {
+ "description": "Block access to the Add-ons Mananger (about:addons).",
+ "first_available": "60.0",
+
+ "type": "boolean",
+ "enum": [true]
+ },
+
"BlockAboutConfig": {
"description": "Blocks access to the about:config page.",
"first_available": "60.0",
"type": "boolean",
"enum": [true]
},
--- a/browser/components/enterprisepolicies/tests/browser/browser.ini
+++ b/browser/components/enterprisepolicies/tests/browser/browser.ini
@@ -7,16 +7,17 @@ support-files =
config_broken_json.json
[browser_policies_broken_json.js]
[browser_policies_popups_cookies_addons_flash.js]
[browser_policies_setAndLockPref_API.js]
[browser_policies_simple_policies.js]
[browser_policies_validate_and_parse_API.js]
[browser_policy_app_update.js]
+[browser_policy_block_about_addons.js]
[browser_policy_block_about_config.js]
[browser_policy_block_about_profiles.js]
[browser_policy_block_about_support.js]
[browser_policy_block_set_desktop_background.js]
[browser_policy_default_browser_check.js]
[browser_policy_disable_fxscreenshots.js]
[browser_policy_display_bookmarks.js]
[browser_policy_disable_formhistory.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_block_about_addons.js
@@ -0,0 +1,29 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+add_task(async function setup() {
+ await setupPolicyEngineWithJson({
+ "policies": {
+ "BlockAboutAddons": true
+ }
+ });
+});
+
+add_task(async function test_about_addons() {
+ let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:addons", false);
+
+ await ContentTask.spawn(tab.linkedBrowser, null, async function() {
+ ok(content.document.documentURI.startsWith("about:neterror"),
+ "about:addons should display the net error page");
+
+ // There is currently a testing-specific race condition that causes this test
+ // to fail, but it is not a problem if we test after the first page load.
+ // Until the race condition is fixed, just make sure to test this *after*
+ // testing the page load.
+ is(Services.policies.isAllowed("about:addons"), false,
+ "Policy Engine should report about:addons as not allowed");
+ });
+
+ await BrowserTestUtils.removeTab(tab);
+});