Bug 1056035 - Hide the separator if there are no visible items above it. r=Unfocused

This commit is contained in:
Mike Quested 2014-09-29 05:01:00 -04:00
parent 42346ce81a
commit f0ea4a8120
2 changed files with 22 additions and 4 deletions

View File

@ -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);
},

View File

@ -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() {