Commit 43797dba authored by Kirk Steuber's avatar Kirk Steuber
Browse files

Bug 1429120 - Create an enterprise policy to display the menu bar by default r=Felipe,Gijs

MozReview-Commit-ID: EJvtw5nbqaV

--HG--
extra : rebase_source : f2895a34bdcd56fae6052008930572cc7a3b32c1
parent 3b741a6b
......@@ -11,8 +11,13 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "gXulStore",
"@mozilla.org/xul/xulstore;1",
"nsIXULStore");
const PREF_LOGLEVEL = "browser.policies.loglevel";
const PREF_MENU_ALREADY_DISPLAYED = "browser.policies.menuBarWasDisplayed";
const BROWSER_DOCUMENT_URL = "chrome://browser/content/browser.xul";
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = Cu.import("resource://gre/modules/Console.jsm", {});
......@@ -36,6 +41,23 @@ this.Policies = {
}
},
"display_menu_bar": {
onBeforeUIStartup(manager, param) {
if (param == true) {
// 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.");
}
}
}
},
"dont_check_default_browser": {
onBeforeUIStartup(manager, param) {
setAndLockPref("browser.shell.checkDefaultBrowser", false);
......
......@@ -10,6 +10,14 @@
"enum": [true]
},
"display_menu_bar": {
"description": "Causes the menu bar to be displayed by default.",
"first_available": "60.0",
"type": "boolean",
"enum": [true]
},
"dont_check_default_browser": {
"description": "Don't check for the default browser on startup.",
"first_available": "60.0",
......
......@@ -8,6 +8,7 @@ support-files =
config_setAndLockPref.json
config_simple_policies.json
config_broken_json.json
config_display_menu.json
[browser_policies_broken_json.js]
[browser_policies_popups_cookies_addons_flash.js]
......@@ -15,3 +16,4 @@ support-files =
[browser_policies_simple_policies.js]
[browser_policies_validate_and_parse_API.js]
[browser_policy_default_browser_check.js]
[browser_policy_display_menu.js]
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function setup() {
await setupPolicyEngineWithJson("config_display_menu.json");
});
add_task(async function test_menu_shown() {
// Since testing will apply the policy after the browser has already started,
// we will need to open a new window to actually see the menu bar
let newWin = await BrowserTestUtils.openNewBrowserWindow();
let menuBar = newWin.document.getElementById("toolbar-menubar");
is(menuBar.getAttribute("autohide"), "false",
"The menu bar should not be hidden");
await BrowserTestUtils.closeWindow(newWin);
});
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