Bug 1700503, insert enterprise policy support menu item to app menu r=mkaply

Differential Revision: https://phabricator.services.mozilla.com/D109569
This commit is contained in:
Emma Malysz 2021-03-24 20:48:28 +00:00
Родитель 829131f372
Коммит 993984618c
2 изменённых файлов: 59 добавлений и 2 удалений

Просмотреть файл

@ -687,7 +687,15 @@ const PanelUI = {
let helpMenu = document.getElementById("menu_HelpPopup");
let items = this.getElementsByTagName("vbox")[0];
let attrs = ["command", "oncommand", "onclick", "key", "disabled"];
let attrs = [
"command",
"oncommand",
"onclick",
"key",
"disabled",
"accesskey",
"label",
];
// Remove all buttons from the view
while (items.firstChild) {
@ -715,7 +723,9 @@ const PanelUI = {
// We have AppMenu-specific strings for the Help menu. By convention,
// their localization IDs are set on "appmenu-data-l10n-id" attributes.
let l10nId = node.getAttribute("appmenu-data-l10n-id");
button.setAttribute("data-l10n-id", l10nId);
if (l10nId) {
button.setAttribute("data-l10n-id", l10nId);
}
if (node.id) {
button.id = "appMenu_" + node.id;
@ -732,6 +742,20 @@ const PanelUI = {
}
fragment.appendChild(button);
}
// The Enterprise Support menu item has a different location than its
// placement in the menubar, so we need to specify it here.
let helpPolicySupport = fragment.querySelector(
"#appMenu_helpPolicySupport"
);
if (helpPolicySupport) {
fragment.insertBefore(
helpPolicySupport,
fragment.querySelector("#appMenu_menu_HelpPopup_reportPhishingtoolmenu")
.nextSibling
);
}
items.appendChild(fragment);
},

Просмотреть файл

@ -34,3 +34,36 @@ add_task(async function test_help_menu() {
"The policy menu should have the correct access key."
);
});
add_task(async function test_help_menu_app_menu() {
is(
Services.policies.getSupportMenu().URL.href,
"https://example.com/",
"The policy should have the correct URL."
);
let menuButton = document.getElementById("PanelUI-menu-button");
menuButton.click();
await BrowserTestUtils.waitForEvent(window.PanelUI.mainView, "ViewShown");
let helpButtonId = PanelUI.protonAppMenuEnabled
? "appMenu-help-button2"
: "appMenu-help-button";
document.getElementById(helpButtonId).click();
await BrowserTestUtils.waitForEvent(
document.getElementById("PanelUI-helpView"),
"ViewShown"
);
let supportMenu = document.getElementById("appMenu_helpPolicySupport");
is(supportMenu.hidden, false, "The policy menu should be visible.");
is(
supportMenu.getAttribute("label"),
"Title",
"The policy menu should have the correct title."
);
is(
supportMenu.getAttribute("accesskey"),
"T",
"The policy menu should have the correct access key."
);
});