Bug 1557286 - should preventDefault the event after showing an input field contextmenu to avoid other context menus showing. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D33935

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Magnus Melin 2019-06-08 18:27:02 +00:00
Родитель 1eb526e657
Коммит e5b2ccb6ee
3 изменённых файлов: 14 добавлений и 0 удалений

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

@ -92,4 +92,7 @@ window.addEventListener("contextmenu", (e) => {
goUpdateGlobalEditMenuItems(true);
popup.openPopupAtScreen(e.screenX, e.screenY, true);
// Don't show any other context menu at the same time. There can be a
// context menu from an ancestor too but we only want to show this one.
e.preventDefault();
});

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

@ -23,8 +23,15 @@
<command id="cmd_switchTextDirection" oncommand="goDoCommand('cmd_switchTextDirection');"/>
</commandset>
<menupopup id="outer-context-menu">
<menuseparator id="customizeMailToolbarMenuSeparator"/>
<menuitem id="hello" label="Hello" accesskey="H"/>
</menupopup>
<hbox context="outer-context-menu">
<html:textarea />
<html:input />
<textbox is="search-textbox"/>
</hbox>
</window>

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

@ -55,6 +55,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1513343
ok(contextmenu, "context menu exists after right click");
await popupshown;
// Check that we only got the one context menu, and not two.
let outerContextmenu = win.document.getElementById("outer-context-menu");
ok(outerContextmenu.state == "closed", "the outer context menu state is is not closed, it's: " + outerContextmenu.state);
ok(!contextmenu.querySelector("[command=cmd_undo]").hasAttribute("disabled"), "undo enabled");
ok(contextmenu.querySelector("[command=cmd_cut]").hasAttribute("disabled"), "cut disabled");
ok(contextmenu.querySelector("[command=cmd_copy]").hasAttribute("disabled"), "copy disabled");