Commit 429b8b51 authored by Daniel Varga's avatar Daniel Varga
Browse files

Backed out changeset f723268009a9 (bug 1587492) for browser chrome failure at...

Backed out changeset f723268009a9 (bug 1587492) for browser chrome failure at browser/browser_policy_display_menu.js
parent 02792a42
...@@ -2108,10 +2108,6 @@ var gBrowserInit = { ...@@ -2108,10 +2108,6 @@ var gBrowserInit = {
window.fullScreen = true; window.fullScreen = true;
} }
} }
if (!Services.policies.isAllowed("hideShowMenuBar")) {
document.getElementById("toolbar-menubar").removeAttribute("toolbarname");
}
}, },
_setInitialFocus() { _setInitialFocus() {
......
...@@ -584,53 +584,18 @@ var Policies = { ...@@ -584,53 +584,18 @@ var Policies = {
DisplayMenuBar: { DisplayMenuBar: {
onBeforeUIStartup(manager, param) { onBeforeUIStartup(manager, param) {
let value; let value = (!param).toString();
if ( // This policy is meant to change the default behavior, not to force it.
typeof param === "boolean" || // If this policy was alreay applied and the user chose to re-hide the
param == "default-on" || // menu bar, do not show it again.
param == "default-off" runOncePerModification("displayMenuBar", value, () => {
) {
switch (param) {
case "default-on":
value = "false";
break;
case "default-off":
value = "true";
break;
default:
value = (!param).toString();
break;
}
// This policy is meant to change the default behavior, not to force it.
// If this policy was already applied and the user chose to re-hide the
// menu bar, do not show it again.
runOncePerModification("displayMenuBar", value, () => {
gXulStore.setValue(
BROWSER_DOCUMENT_URL,
"toolbar-menubar",
"autohide",
value
);
});
} else {
switch (param) {
case "always":
value = "false";
break;
case "never":
// Make sure Alt key doesn't show the menubar
setAndLockPref("ui.key.menuAccessKeyFocuses", false);
value = "true";
break;
}
gXulStore.setValue( gXulStore.setValue(
BROWSER_DOCUMENT_URL, BROWSER_DOCUMENT_URL,
"toolbar-menubar", "toolbar-menubar",
"autohide", "autohide",
value value
); );
manager.disallowFeature("hideShowMenuBar"); });
}
}, },
}, },
......
...@@ -277,8 +277,7 @@ ...@@ -277,8 +277,7 @@
}, },
"DisplayMenuBar": { "DisplayMenuBar": {
"type": ["boolean", "string"], "type": "boolean"
"enum": ["always", "never", "default-on", "default-off"]
}, },
"DNSOverHTTPS": { "DNSOverHTTPS": {
......
...@@ -3,87 +3,24 @@ ...@@ -3,87 +3,24 @@
"use strict"; "use strict";
add_task(async function test_menu_shown_boolean() { add_task(async function setup() {
await setupPolicyEngineWithJson({ await setupPolicyEngineWithJson({
policies: { policies: {
DisplayMenuBar: true, DisplayMenuBar: true,
}, },
}); });
// 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);
}); });
add_task(async function test_menu_shown_string() { add_task(async function test_menu_shown() {
await setupPolicyEngineWithJson({
policies: {
DisplayMenuBar: "default-on",
},
});
// Since testing will apply the policy after the browser has already started, // 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 // we will need to open a new window to actually see the menu bar
let newWin = await BrowserTestUtils.openNewBrowserWindow(); let newWin = await BrowserTestUtils.openNewBrowserWindow();
let menubar = newWin.document.getElementById("toolbar-menubar"); let menuBar = newWin.document.getElementById("toolbar-menubar");
is( is(
menubar.getAttribute("autohide"), menuBar.getAttribute("autohide"),
"false", "false",
"The menu bar should not be hidden" "The menu bar should not be hidden"
); );
is(
menubar.hasAttribute("toolbarname"),
true,
"Menu bar should have a toolbarname"
);
await BrowserTestUtils.closeWindow(newWin); await BrowserTestUtils.closeWindow(newWin);
}); });
add_task(async function test_menubar_on() {
await setupPolicyEngineWithJson({
policies: {
DisplayMenuBar: "always",
},
});
let newWin = await BrowserTestUtils.openNewBrowserWindow();
let menubar = newWin.document.getElementById("toolbar-menubar");
is(
menubar.hasAttribute("inactive"),
false,
"Menu bar should not have inactive"
);
is(
menubar.hasAttribute("toolbarname"),
false,
"Menu bar should not have a toolbarname"
);
await BrowserTestUtils.closeWindow(newWin);
});
add_task(async function test_menubar_off() {
await setupPolicyEngineWithJson({
policies: {
DisplayMenuBar: "never",
},
});
let newWin = await BrowserTestUtils.openNewBrowserWindow();
let menubar = newWin.document.getElementById("toolbar-menubar");
is(menubar.hasAttribute("inactive"), true, "Menu bar should have inactive");
is(
menubar.hasAttribute("toolbarname"),
false,
"Menu bar should not have a toolbarname"
);
await BrowserTestUtils.closeWindow(newWin);
});
...@@ -39,10 +39,7 @@ var JsonSchemaValidator = { ...@@ -39,10 +39,7 @@ var JsonSchemaValidator = {
}; };
function validateAndParseParamRecursive(param, properties) { function validateAndParseParamRecursive(param, properties) {
// If the param is a boolean, don't check the enum values. if (properties.enum) {
// This allows for values that are both a string with enums
// and a boolean.
if (properties.enum && typeof param !== "boolean") {
if (properties.enum.includes(param)) { if (properties.enum.includes(param)) {
return [true, param]; return [true, param];
} }
......
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