зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1553387 - Use createXULElement for 'window' menuitems on osx r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D32166 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7bd552ead5
Коммит
2af088c3e3
|
@ -1,3 +1,5 @@
|
|||
[DEFAULT]
|
||||
|
||||
[browser_file_menu_import_wizard.js]
|
||||
[browser_window_menu_list.js]
|
||||
skip-if = os != "mac" # Mac only feature
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_window_menu_list() {
|
||||
// This title is different depending on the build. For example, it's "Nightly"
|
||||
// for a local build, "Mozilla Firefox" for an official release build.
|
||||
const windowTitle = window.document.title;
|
||||
await checkWindowMenu([windowTitle, "Browser chrome tests"]);
|
||||
let newWindow = await BrowserTestUtils.openNewBrowserWindow();
|
||||
await checkWindowMenu([windowTitle, "Browser chrome tests", windowTitle]);
|
||||
await BrowserTestUtils.closeWindow(newWindow);
|
||||
});
|
||||
|
||||
async function checkWindowMenu(labels) {
|
||||
let menu = document.querySelector("#windowMenu");
|
||||
// We can't toggle menubar items on OSX, so mocking instead.
|
||||
await new Promise(resolve => {
|
||||
menu.addEventListener("popupshown", resolve, { once: true });
|
||||
menu.dispatchEvent(new MouseEvent("popupshowing"));
|
||||
menu.dispatchEvent(new MouseEvent("popupshown"));
|
||||
});
|
||||
|
||||
let menuitems = [...menu.querySelectorAll("menuseparator ~ menuitem")];
|
||||
is(menuitems.length, labels.length, "Correct number of windows in the menu");
|
||||
is(menuitems.map(item => item.label).join(","), labels.join(","), "Correct labels on menuitems");
|
||||
for (let menuitem of menuitems) {
|
||||
ok(menuitem instanceof customElements.get("menuitem"), "sibling is menuitem");
|
||||
}
|
||||
|
||||
// We can't toggle menubar items on OSX, so mocking instead.
|
||||
await new Promise(resolve => {
|
||||
menu.addEventListener("popuphidden", resolve, { once: true });
|
||||
menu.dispatchEvent(new MouseEvent("popuphiding"));
|
||||
menu.dispatchEvent(new MouseEvent("popuphidden"));
|
||||
});
|
||||
}
|
|
@ -10,7 +10,7 @@ function macWindowMenuDidShow() {
|
|||
if (win.document.documentElement.getAttribute("inwindowmenu") == "false") {
|
||||
continue;
|
||||
}
|
||||
let item = document.createElement("menuitem");
|
||||
let item = document.createXULElement("menuitem");
|
||||
item.setAttribute("label", win.document.title);
|
||||
if (win == window) {
|
||||
item.setAttribute("checked", "true");
|
||||
|
|
Загрузка…
Ссылка в новой задаче