Commit 4c8ecf78 authored by Felipe Gomes's avatar Felipe Gomes
Browse files

Bug 1440194 - Sort list of policies alphabetically. r=me

parent 86a9ff73
......@@ -61,60 +61,32 @@ this.Policies = {
}
},
"DisableAppUpdate": {
onBeforeAddons(manager, param) {
if (param) {
manager.disallowFeature("appUpdate");
}
}
},
"DisplayMenuBar": {
"BlockSetDesktopBackground": {
onBeforeUIStartup(manager, param) {
if (param) {
// This policy is meant to change the default behavior, not to force it.
// If this policy was alreay applied and the user chose to re-hide the
// menu bar, do not show it again.
if (!Services.prefs.getBoolPref(PREF_MENU_ALREADY_DISPLAYED, false)) {
log.debug("Showing the menu bar");
gXulStore.setValue(BROWSER_DOCUMENT_URL, "toolbar-menubar", "autohide", "false");
Services.prefs.setBoolPref(PREF_MENU_ALREADY_DISPLAYED, true);
} else {
log.debug("Not showing the menu bar because it has already been shown.");
}
manager.disallowFeature("setDesktopBackground", true);
}
}
},
"DisplayBookmarksToolbar": {
"Cookies": {
onBeforeUIStartup(manager, param) {
if (param) {
// This policy is meant to change the default behavior, not to force it.
// If this policy was alreay applied and the user chose to re-hide the
// bookmarks toolbar, do not show it again.
if (!Services.prefs.getBoolPref(PREF_BOOKMARKS_ALREADY_DISPLAYED, false)) {
log.debug("Showing the bookmarks toolbar");
gXulStore.setValue(BROWSER_DOCUMENT_URL, "PersonalToolbar", "collapsed", "false");
Services.prefs.setBoolPref(PREF_BOOKMARKS_ALREADY_DISPLAYED, true);
} else {
log.debug("Not showing the bookmarks toolbar because it has already been shown.");
}
}
addAllowDenyPermissions("cookie", param.Allow, param.Block);
}
},
"BlockSetDesktopBackground": {
"CreateMasterPassword": {
onBeforeUIStartup(manager, param) {
if (param) {
manager.disallowFeature("setDesktopBackground", true);
if (!param) {
manager.disallowFeature("createMasterPassword");
}
}
},
"CreateMasterPassword": {
onBeforeUIStartup(manager, param) {
if (!param) {
manager.disallowFeature("createMasterPassword");
"DisableAppUpdate": {
onBeforeAddons(manager, param) {
if (param) {
manager.disallowFeature("appUpdate");
}
}
},
......@@ -143,27 +115,49 @@ this.Policies = {
}
},
"DontCheckDefaultBrowser": {
"DisplayBookmarksToolbar": {
onBeforeUIStartup(manager, param) {
setAndLockPref("browser.shell.checkDefaultBrowser", false);
if (param) {
// This policy is meant to change the default behavior, not to force it.
// If this policy was alreay applied and the user chose to re-hide the
// bookmarks toolbar, do not show it again.
if (!Services.prefs.getBoolPref(PREF_BOOKMARKS_ALREADY_DISPLAYED, false)) {
log.debug("Showing the bookmarks toolbar");
gXulStore.setValue(BROWSER_DOCUMENT_URL, "PersonalToolbar", "collapsed", "false");
Services.prefs.setBoolPref(PREF_BOOKMARKS_ALREADY_DISPLAYED, true);
} else {
log.debug("Not showing the bookmarks toolbar because it has already been shown.");
}
}
}
},
"FlashPlugin": {
"DisplayMenuBar": {
onBeforeUIStartup(manager, param) {
addAllowDenyPermissions("plugin:flash", param.Allow, param.Block);
if (param) {
// This policy is meant to change the default behavior, not to force it.
// If this policy was alreay applied and the user chose to re-hide the
// menu bar, do not show it again.
if (!Services.prefs.getBoolPref(PREF_MENU_ALREADY_DISPLAYED, false)) {
log.debug("Showing the menu bar");
gXulStore.setValue(BROWSER_DOCUMENT_URL, "toolbar-menubar", "autohide", "false");
Services.prefs.setBoolPref(PREF_MENU_ALREADY_DISPLAYED, true);
} else {
log.debug("Not showing the menu bar because it has already been shown.");
}
}
}
},
"Popups": {
"DontCheckDefaultBrowser": {
onBeforeUIStartup(manager, param) {
addAllowDenyPermissions("popup", param.Allow, param.Block);
setAndLockPref("browser.shell.checkDefaultBrowser", false);
}
},
"RememberPasswords": {
"FlashPlugin": {
onBeforeUIStartup(manager, param) {
setAndLockPref("signon.rememberSignons", param);
addAllowDenyPermissions("plugin:flash", param.Allow, param.Block);
}
},
......@@ -173,9 +167,15 @@ this.Policies = {
}
},
"Cookies": {
"Popups": {
onBeforeUIStartup(manager, param) {
addAllowDenyPermissions("cookie", param.Allow, param.Block);
addAllowDenyPermissions("popup", param.Allow, param.Block);
}
},
"RememberPasswords": {
onBeforeUIStartup(manager, param) {
setAndLockPref("signon.rememberSignons", param);
}
},
};
......
......@@ -34,65 +34,87 @@
"enum": [true]
},
"DisableAppUpdate": {
"description": "Prevent the browser from updating.",
"BlockSetDesktopBackground": {
"description": "Prevents usage of the \"Set Image as Desktop Background\" feature.",
"first_available": "60.0",
"enterprise_only": true,
"type": "boolean",
"enum": [true]
},
"DisplayMenuBar": {
"description": "Causes the menu bar to be displayed by default.",
"Cookies": {
"description": "Allow or deny websites to set cookies.",
"first_available": "60.0",
"type": "object",
"properties": {
"Allow": {
"type": "array",
"items": {
"type": "origin"
}
},
"Block": {
"type": "array",
"items": {
"type": "origin"
}
}
}
},
"CreateMasterPassword": {
"description": "If false, removes access to create a master password.",
"first_available": "60.0",
"type": "boolean",
"enum": [true]
"enum": [false]
},
"DisplayBookmarksToolbar": {
"description": "Causes the bookmarks toolbar to be displayed by default.",
"DisableAppUpdate": {
"description": "Prevent the browser from updating.",
"first_available": "60.0",
"enterprise_only": true,
"type": "boolean",
"enum": [true]
},
"BlockSetDesktopBackground": {
"description": "Prevents usage of the \"Set Image as Desktop Background\" feature.",
"DisableFirefoxScreenshots": {
"description": "Prevents usage of the Firefox Screenshots feature.",
"first_available": "60.0",
"type": "boolean",
"enum": [true]
},
"CreateMasterPassword": {
"description": "If false, removes access to create a master password.",
"DisableFirefoxStudies": {
"description": "Prevents Firefox from running studies.",
"first_available": "60.0",
"type": "boolean",
"enum": [false]
"enum": [true]
},
"DisableFirefoxScreenshots": {
"description": "Prevents usage of the Firefox Screenshots feature.",
"DisableFormHistory": {
"description": "Don't remember search and form history.",
"first_available": "60.0",
"type": "boolean",
"enum": [true]
},
"DisableFirefoxStudies": {
"description": "Prevents Firefox from running studies.",
"DisplayBookmarksToolbar": {
"description": "Causes the bookmarks toolbar to be displayed by default.",
"first_available": "60.0",
"type": "boolean",
"enum": [true]
},
"DisableFormHistory": {
"description": "Don't remember search and form history.",
"DisplayMenuBar": {
"description": "Causes the menu bar to be displayed by default.",
"first_available": "60.0",
"type": "boolean",
......@@ -129,8 +151,8 @@
}
},
"Popups": {
"description": "Allow or deny popup usage.",
"InstallAddons": {
"description": "Allow or deny popup websites to install webextensions.",
"first_available": "60.0",
"type": "object",
......@@ -151,15 +173,8 @@
}
},
"RememberPasswords": {
"description": "Enforces the setting to allow Firefox to remember saved logins and passwords. Both true and false values are accepted.",
"first_available": "60.0",
"type": "boolean"
},
"InstallAddons": {
"description": "Allow or deny popup websites to install webextensions.",
"Popups": {
"description": "Allow or deny popup usage.",
"first_available": "60.0",
"type": "object",
......@@ -180,26 +195,11 @@
}
},
"Cookies": {
"description": "Allow or deny websites to set cookies.",
"RememberPasswords": {
"description": "Enforces the setting to allow Firefox to remember saved logins and passwords. Both true and false values are accepted.",
"first_available": "60.0",
"type": "object",
"properties": {
"Allow": {
"type": "array",
"items": {
"type": "origin"
}
},
"Block": {
"type": "array",
"items": {
"type": "origin"
}
}
}
"type": "boolean"
}
}
}
......@@ -10,6 +10,7 @@ support-files =
[browser_policies_popups_cookies_addons_flash.js]
[browser_policies_setAndLockPref_API.js]
[browser_policies_simple_policies.js]
[browser_policies_sorted_alphabetically.js]
[browser_policies_validate_and_parse_API.js]
[browser_policy_app_update.js]
[browser_policy_block_about_addons.js]
......@@ -18,11 +19,10 @@ support-files =
[browser_policy_block_about_support.js]
[browser_policy_block_set_desktop_background.js]
[browser_policy_default_browser_check.js]
[browser_policy_disable_formhistory.js]
[browser_policy_disable_fxscreenshots.js]
[browser_policy_disable_masterpassword.js]
[browser_policy_disable_shield.js]
[browser_policy_display_bookmarks.js]
[browser_policy_disable_formhistory.js]
[browser_policy_display_menu.js]
[browser_policy_disable_shield.js]
[browser_policy_remember_passwords.js]
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function checkArrayIsSorted(array, msg) {
let sorted = true;
let sortedArray = array.slice().sort();
for (let i = 0; i < array.length; i++) {
if (array[i] != sortedArray[i]) {
sorted = false;
break;
}
}
ok(sorted, msg);
}
add_task(async function test_policies_sorted() {
let { schema } = ChromeUtils.import("resource:///modules/policies/schema.jsm", {});
let { Policies } = ChromeUtils.import("resource:///modules/policies/Policies.jsm", {});
checkArrayIsSorted(Object.keys(schema.properties), "policies-schema.json is alphabetically sorted.");
checkArrayIsSorted(Object.keys(Policies), "Policies.jsm is alphabetically sorted.");
});
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