diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index b21ffdeb870..bccaa0eb15c 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -437,16 +437,19 @@ var gEventManager = { contextMenu.setAttribute("addontype", addon.type); var menuSep = document.getElementById("addonitem-menuseparator"); - var countEnabledMenuCmds = 0; + var countMenuItemsBeforeSep = 0; for (let child of contextMenu.children) { + if (child == menuSep) { + break; + } if (child.nodeName == "menuitem" && gViewController.isCommandEnabled(child.command)) { - countEnabledMenuCmds++; + countMenuItemsBeforeSep++; } } - // with only one menu item, we hide the menu separator - menuSep.hidden = (countEnabledMenuCmds <= 1); + // Hide the separator if there are no visible menu items before it + menuSep.hidden = (countMenuItemsBeforeSep == 0); }, false); }, diff --git a/toolkit/mozapps/extensions/test/browser/browser_openH264.js b/toolkit/mozapps/extensions/test/browser/browser_openH264.js index 4a8d9bc23a1..1bee700b066 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_openH264.js +++ b/toolkit/mozapps/extensions/test/browser/browser_openH264.js @@ -197,6 +197,21 @@ add_task(function* testInstalledDetails() { el = doc.getElementById("detail-warning"); is_element_hidden(el, "Warning notification is hidden."); el = doc.getElementsByTagName("setting")[0]; + + let contextMenu = doc.getElementById("addonitem-popup"); + let deferred = Promise.defer(); + let listener = () => { + contextMenu.removeEventListener("popupshown", listener, false); + deferred.resolve(); + }; + contextMenu.addEventListener("popupshown", listener, false); + el = doc.getElementsByClassName("detail-view-container")[0]; + EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); + EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); + yield deferred.promise; + let menuSep = doc.getElementById("addonitem-menuseparator"); + is_element_hidden(menuSep, "Menu separator is hidden."); + contextMenu.hidePopup(); }); add_task(function* testPreferencesButton() {