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

This commit is contained in:
Daniel Varga
2019-11-01 21:12:07 +02:00
parent ca3c1510db
commit 27cbf88130
5 changed files with 13 additions and 119 deletions

View File

@@ -2108,10 +2108,6 @@ var gBrowserInit = {
window.fullScreen = true;
}
}
if (!Services.policies.isAllowed("hideShowMenuBar")) {
document.getElementById("toolbar-menubar").removeAttribute("toolbarname");
}
},
_setInitialFocus() {

View File

@@ -584,53 +584,18 @@ var Policies = {
DisplayMenuBar: {
onBeforeUIStartup(manager, param) {
let value;
if (
typeof param === "boolean" ||
param == "default-on" ||
param == "default-off"
) {
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;
}
let value = (!param).toString();
// 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.
runOncePerModification("displayMenuBar", value, () => {
gXulStore.setValue(
BROWSER_DOCUMENT_URL,
"toolbar-menubar",
"autohide",
value
);
manager.disallowFeature("hideShowMenuBar");
}
});
},
},

View File

@@ -277,8 +277,7 @@
},
"DisplayMenuBar": {
"type": ["boolean", "string"],
"enum": ["always", "never", "default-on", "default-off"]
"type": "boolean"
},
"DNSOverHTTPS": {

View File

@@ -3,87 +3,24 @@
"use strict";
add_task(async function test_menu_shown_boolean() {
add_task(async function setup() {
await setupPolicyEngineWithJson({
policies: {
DisplayMenuBar: true,
},
});
});
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");
let menuBar = newWin.document.getElementById("toolbar-menubar");
is(
menubar.getAttribute("autohide"),
menuBar.getAttribute("autohide"),
"false",
"The menu bar should not be hidden"
);
await BrowserTestUtils.closeWindow(newWin);
});
add_task(async function test_menu_shown_string() {
await setupPolicyEngineWithJson({
policies: {
DisplayMenuBar: "default-on",
},
});
// 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"
);
is(
menubar.hasAttribute("toolbarname"),
true,
"Menu bar should have a toolbarname"
);
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);
});

View File

@@ -39,10 +39,7 @@ var JsonSchemaValidator = {
};
function validateAndParseParamRecursive(param, properties) {
// If the param is a boolean, don't check the enum values.
// This allows for values that are both a string with enums
// and a boolean.
if (properties.enum && typeof param !== "boolean") {
if (properties.enum) {
if (properties.enum.includes(param)) {
return [true, param];
}