Bug 1824746 - Don't show a context menu if there's no download "selected". r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D173753
This commit is contained in:
Marco Bonardo 2023-03-28 12:34:01 +00:00
Родитель 2988d43caf
Коммит 5be3afc060
2 изменённых файлов: 25 добавлений и 0 удалений

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

@ -1019,6 +1019,7 @@ var DownloadsView = {
onDownloadContextMenu(aEvent) {
let element = aEvent.originalTarget.closest("richlistitem");
if (!element) {
aEvent.preventDefault();
return;
}
// Ensure the selected item is the expected one, so commands and the

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

@ -83,6 +83,30 @@ add_task(async function test() {
cmd_delete: true,
});
info("Check we don't open a context menu between items.");
function listener() {
Assert.ok(false, "Should not open a context menu");
}
document.addEventListener("popupshown", listener);
let listRect = downloadsListBox.getBoundingClientRect();
let firstRect = first.getBoundingClientRect();
let secondRect = second.getBoundingClientRect();
let x = parseInt(firstRect.width / 2);
Assert.greater(
secondRect.y - firstRect.y - firstRect.height,
1,
"There should be a gap of at least 1 px for this test"
);
let y = parseInt(firstRect.y - listRect.y + firstRect.height + 1);
info(`Right click at (${x}, ${y})`);
EventUtils.synthesizeMouse(downloadsListBox, x, y, {
type: "contextmenu",
button: 2,
});
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
await new Promise(r => setTimeout(r, 100));
document.removeEventListener("popupshown", listener);
let hiddenPromise = BrowserTestUtils.waitForEvent(
DownloadsPanel.panel,
"popuphidden"