Bug 1546332 - fix mochitest of browser_ext_menus.js, hint by :darktrojan. r=jorgk DONTBUILD
authorKhushil Mistry <khushil324@gmail.com>
Thu, 30 May 2019 10:22:07 +0200
changeset 35722 6d4ef59e9ed0a36b16f5c04ff90ee14cad6c340e
parent 35721 bfac42da27a2dc34ba30781fc08bd97155933fdc
child 35723 78f7fd722424f609709ff3bd2eba6f0fbcd47b27
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersjorgk
bugs1546332
Bug 1546332 - fix mochitest of browser_ext_menus.js, hint by :darktrojan. r=jorgk DONTBUILD
mail/components/extensions/parent/ext-menus.js
--- a/mail/components/extensions/parent/ext-menus.js
+++ b/mail/components/extensions/parent/ext-menus.js
@@ -889,18 +889,21 @@ const menuTracker = {
       const menu = window.document.getElementById(id);
       menu.addEventListener("popupshowing", menuTracker);
     }
   },
 
   handleEvent(event) {
     const menu = event.target;
     if (menu.id === "tabContextMenu") {
-      const trigger = menu.triggerNode;
-      const tab = trigger.localName === "tab" ? trigger : tabTracker.activeTab;
+      let trigger = menu.triggerNode;
+      while (trigger && trigger.localName != "tab") {
+        trigger = trigger.parentNode;
+      }
+      const tab = trigger || tabTracker.activeTab;
       const pageUrl = tab.linkedBrowser.currentURI.spec;
       gMenuBuilder.build({menu, tab, pageUrl, onTab: true});
     }
     if (menu.id === "folderPaneContext") {
       const trigger = menu.triggerNode;
       const tab = trigger.localName === "tab" ? trigger : tabTracker.activeTab;
       const pageUrl = tab.linkedBrowser.currentURI.spec;
       gMenuBuilder.build({