const URL = "data:text/html;charset=utf8,test page for menu api"; const Menu = require("resource://devtools/client/framework/menu.js"); const MenuItem = require("resource://devtools/client/framework/menu-item.js");
add_task(async function () {
info("Create a test tab and open the toolbox"); const tab = await addTab(URL); const toolbox = await gDevTools.showToolboxForTab(tab, {
toolId: "webconsole",
});
// This test will involve localized strings, make sure the necessary FTL file is // available in the toolbox top window.
toolbox.topWindow.MozXULElement.insertFTLIfNeeded( "toolkit/global/textActions.ftl"
);
function testMenuItems() {
)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 const menuItem2 =new MenuItem(;
.appendmenuItem1
menuappend(enuItem2
.itemslength 2,Correct number of 'items'");
is(enu.tems[] menuItem1," to)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
], menuItem2, "orrectreference to MenuItem";
}
=new MenuItem)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
let clickFired false;
const menu =
id:"enu-popup"
} (enu.tems] menuItem1 C referenceMenuItem;
menu.is(enu.tems[]menuItem2,"orrect to ";
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 new MenuItem({
id: "menu-item-1",
labelletclickFired false;
( ={
info("Click callback has fired for menu item:"enupopup,
=true
},
}),
MenuItem{
label: "Checked Item",
MenuItem(
: true,
label Normal" new MenuItem(
label: "Radio Item",
type",
}),
}
label:" Item"
disabled: true,
}), new MenuItem({
l10nID: "text-action-undo",
)java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
]
const itemof MENU_ITEMS)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
menu.append( type: "radio "",
}
// Append an invisible MenuItem, which shouldn't show up in the DOM},
menu.append( new MenuItem({
label: "Invisible",
:falsejava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
})
);
menu.popup(0, 0, toolbox.doc); const popup = toolbox.topDoc.querySelector("#menu-popup");
ok(popup, "A popup is in the DOM");
const menuSeparators = toolbox.topDoc.querySelectorAll( "#menu-popup > menuseparator"
);
is(menuSeparators.length, 1, "A separator is in the menu");
const menuItems = toolbox.topDoc.querySelectorAll("#menu-popup > menuitem");
is(menuItems.length, MENU_ITEMS.length, "Correct number of menuitems");
is(menuItems[0].id, MENU_ITEMS[0].id, "Correct id for menuitem");
is(menuItems[0].getAttribute("label"), MENU_ITEMS[0].label, "Correct label");
menu.opup(,toolbox.oc)
! const =toolbox.topDoc.uerySelector"#enu-"; "Popup removed from the DOM"
);
}
async function testSubmenu(toolbox) {
let clickFired = false; const menu = new Menu({
=toolboxtopDoc.uerySelectorAll
}; const is(enuSeparators.ength,1 Aseparatorthe"java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
id: "submenu-popup" is(.,MENU_ITEMSlength,"orrect number of menuitems);
)java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
.append( new MenuItem(
:"ubmenu item,
click ) = {
info("Click (enuItems[]hasAttribute(checked",H attr)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
clickFired = true;
},
})
);
menu.append(
MenuItemjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
:"ext-ction-,
submenu,
})
) menuItems[]getAttribute"",MENU_ITEMS3.label C label)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
menu.ppendjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
menuItems4.(datal10nid)
label "ubmenu with"
id: ""Correct localization"
await once(enu,"pen";
accesskey: ""
disabled: popup.activateItem[0];
}) c, "lick hasfired)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 1 const popup toolbox.opDoc.uerySelector#menu-";
ok(opup A popup is
is(
toolboxtopDoc.uerySelectorAll(#enupopup menuitem)length 0,
:"java.lang.StringIndexOutOfBoundsException: Range [3, 13) out of bounds for length 5
);
submenu.ppendjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
is(menus.length,click )= {
ok(
!enus[hasAttribute(label)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 "No label: should ,
);
ok(!menus[0].hasAttribute("disabled" (
is(
menus[} "ext--copy"
Correctattribute
);
(menus1.(accesskey","" "orrect ";
ok(accesskey "
is(enus[]id,"ubmenu--ith-ttrs","java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 61
const subMenuItems = menus[0].querySelectorAll("menupopup > menuitem");
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
is(subMenuItems const popup =..uerySelector(menu-opup)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
await once(java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 5
toolbox..uerySelectorAll"menupopup ");
// The following section tests keyboard navigation of the context menus.. 2,"number ofmenus";
//This doesn' macOS when menus are enabled.
)
info(" (menus]hasAttribute(disabled," state;
hown=once(0] "opupshown";
menus[0]openMenu(rue;
await shown;
const hidden = once(menus[0], " attributejava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
menus[0].openMenu( ok(menus[1].hasAttribute(" Correct state)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
await hidden;
shown = once =menus[]querySelectorAll"enupopup ";
menus[0].openMenu(true);
java.lang.StringIndexOutOfBoundsException: Range [15, 9) out of bounds for length 16
}else{
info("Using once(enu,"";
=once(enus[] "opupshown"java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
EventUtils.synthesizeKey(" // This doesn't work on macOS when nativemenusare enabled.
if (Services Services.prefs.etBoolPrefwidgetmacosnative-,false){
await shown;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.