Bug 1693577 - Pass on original event to inluce triggerNode in popupshowing event. r=mossop

Differential Revision: https://phabricator.services.mozilla.com/D105649
This commit is contained in:
John Bieling 2021-04-01 20:30:41 +00:00
Родитель 1fd7046f00
Коммит b422f71da0
3 изменённых файлов: 47 добавлений и 1 удалений

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

@ -128,7 +128,7 @@ window.addEventListener("contextmenu", e => {
}
goUpdateGlobalEditMenuItems(true);
popup.openPopupAtScreen(e.screenX, e.screenY, true);
popup.openPopupAtScreen(e.screenX, e.screenY, true, e);
// 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();

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

@ -60,6 +60,7 @@ skip-if = ((debug || asan) && os == "win" && bits == 64)
skip-if = true # bug 1399845 tracks re-enabling this test.
[browser_bug594509.js]
[browser_bug982298.js]
[browser_bug1693577.js]
[browser_cancel_starting_autoscrolling_requested_by_background_tab.js]
[browser_charsetMenu_swapBrowsers.js]
[browser_click_event_during_autoscrolling.js]

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

@ -0,0 +1,45 @@
/*
* This test checks that the popupshowing event for input fields, which do not
* have a dedicated contextmenu event, but use the global one (added by
* editMenuOverlay.js, see bug 1693577) include a triggerNode.
*
* The search-input field of the browser-sidebar is one of the rare cases in
* mozilla-central, which can be used to test this. There are a few more in
* comm-central, which need the triggerNode information.
*/
add_task(async function test_search_input_popupshowing() {
let sidebar = document.getElementById("sidebar");
let loadPromise = BrowserTestUtils.waitForEvent(sidebar, "load", true);
SidebarUI.toggle("viewBookmarksSidebar");
await loadPromise;
let inputField = sidebar.contentDocument.getElementById("search-box")
.inputField;
let popupShownPromise = new Promise(resolve => {
sidebar.contentWindow.addEventListener(
"popupshowing",
e => {
Assert.equal(
e.target.triggerNode?.id,
"search-box",
"Popupshowing event for the search input includes triggernode."
);
resolve();
},
{ once: true }
);
});
EventUtils.synthesizeMouseAtCenter(
inputField,
{
type: "contextmenu",
button: 2,
},
sidebar.contentWindow
);
await popupShownPromise;
SidebarUI.toggle("viewBookmarksSidebar");
});