This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch geckoview-99.0.1-11.0-1 in repository tor-browser.
commit 31b61b7333d73f7823894f2d72fb1483d1d466f6 Author: Dão Gottwald dao@mozilla.com AuthorDate: Sun Mar 27 20:16:01 2022 +0200
Bug 1758294 - Download panel context menu acts on the first item in the list instead of the one clicked on. r=mak a=dmeehan --- browser/components/downloads/content/downloads.js | 5 +- .../browser_downloads_panel_context_menu.js | 60 ++++++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-)
diff --git a/browser/components/downloads/content/downloads.js b/browser/components/downloads/content/downloads.js index 0c1e0c2140235..1d5009dff14f1 100644 --- a/browser/components/downloads/content/downloads.js +++ b/browser/components/downloads/content/downloads.js @@ -278,7 +278,10 @@ var DownloadsPanel = { handleEvent(aEvent) { switch (aEvent.type) { case "mousemove": - if (this.panel.contains(document.activeElement)) { + if ( + !DownloadsView.contextMenuOpen && + this.panel.contains(document.activeElement) + ) { // Let mouse movement remove focus rings and reset focus in the panel. // This behavior is copied from PanelMultiView. document.activeElement.blur(); diff --git a/browser/components/downloads/test/browser/browser_downloads_panel_context_menu.js b/browser/components/downloads/test/browser/browser_downloads_panel_context_menu.js index 047f54f26eab3..f2ec29fa490a3 100644 --- a/browser/components/downloads/test/browser/browser_downloads_panel_context_menu.js +++ b/browser/components/downloads/test/browser/browser_downloads_panel_context_menu.js @@ -308,6 +308,43 @@ const TestCasesDeletedFile = [ }, ];
+const TestCasesMultipleFiles = [ + { + name: "Multiple files", + prefEnabled: true, + downloads: [ + { + state: DownloadsCommon.DOWNLOAD_FINISHED, + contentType: "text/plain", + target: {}, + source: { + referrerInfo: exampleRefInfo, + }, + }, + { + state: DownloadsCommon.DOWNLOAD_FINISHED, + contentType: "text/plain", + target: {}, + source: { + referrerInfo: exampleRefInfo, + }, + deleted: true, + }, + ], + expected: { + menu: [ + MENU_ITEMS.alwaysOpenSimilarFiles, + MENU_ITEMS.openReferrer, + MENU_ITEMS.copyLocation, + MENU_ITEMS.separator, + MENU_ITEMS.delete, + MENU_ITEMS.clearList, + ], + }, + itemIndex: 1, + }, +]; + add_task(async function test_setUp() { // remove download files, empty out collections let downloadList = await Downloads.getList(Downloads.ALL); @@ -410,6 +447,7 @@ async function testDownloadContextMenu({ expected, prefEnabled, deleted, + itemIndex = 0, }) { info( `Setting browser.download.improvements_to_download_panel to ${prefEnabled}` @@ -443,13 +481,29 @@ async function testDownloadContextMenu({ return downloadsListBox.childElementCount == downloads.length; });
- info("trigger the context menu"); - let itemTarget = document.querySelector( - "#downloadsListBox richlistitem .downloadMainArea" + let itemTarget = document + .querySelectorAll("#downloadsListBox richlistitem") + [itemIndex].querySelector(".downloadMainArea"); + EventUtils.synthesizeMouse(itemTarget, 1, 1, { type: "mousemove" }); + is( + DownloadsView.richListBox.selectedIndex, + 0, + "moving the mouse resets the richlistbox's selected index" );
+ info("trigger the context menu"); let contextMenu = await openContextMenu(itemTarget);
+ // FIXME: This works in practice, but simulating the context menu opening + // doesn't seem to automatically set the selected index. + DownloadsView.richListBox.selectedIndex = itemIndex; + EventUtils.synthesizeMouse(itemTarget, 1, 1, { type: "mousemove" }); + is( + DownloadsView.richListBox.selectedIndex, + itemIndex, + "selected index after opening the context menu and moving the mouse" + ); + info("context menu should be open, verify its menu items"); let result = verifyContextMenu(contextMenu, expected.menu);