Bug 1383458 - disable pin to overflow / move to panel for flexible spacers (and other special items), r=jaws

MozReview-Commit-ID: 4eeKLsjPi6I
This commit is contained in:
Gijs Kruitbosch
2017-07-26 17:28:47 +01:00
parent eb87f9efc6
commit e46e8d77d3
2 changed files with 35 additions and 1 deletions

View File

@@ -5483,8 +5483,13 @@ function onViewToolbarsPopupShowing(aEvent, aInsertPoint) {
// this case.
let movable = toolbarItem && toolbarItem.parentNode &&
CustomizableUI.isWidgetRemovable(toolbarItem);
let isSpecial = toolbarItem && CustomizableUI.isSpecialWidget(toolbarItem.id);
if (movable) {
moveToPanel.removeAttribute("disabled");
if (isSpecial) {
moveToPanel.setAttribute("disabled", true);
} else {
moveToPanel.removeAttribute("disabled");
}
removeFromToolbar.removeAttribute("disabled");
} else {
moveToPanel.setAttribute("disabled", true);

View File

@@ -429,3 +429,32 @@ add_task(async function custom_context_menus() {
widget.remove();
ok(CustomizableUI.inDefaultState, "Should be in default state after removing button.");
});
// Bug 1383458 - shouldn't enable 'pin to overflow menu' for flexible spaces
add_task(async function flexible_space_context_menu() {
CustomizableUI.addWidgetToArea("spring", "nav-bar");
let springs = document.querySelectorAll("#nav-bar toolbarspring");
let lastSpring = springs[springs.length - 1];
ok(lastSpring, "we added a spring");
let contextMenu = document.getElementById("toolbar-context-menu");
let shownPromise = popupShown(contextMenu);
EventUtils.synthesizeMouse(lastSpring, 2, 2, {type: "contextmenu", button: 2});
await shownPromise;
let expectedEntries = [
[".customize-context-moveToPanel", false],
[".customize-context-removeFromToolbar", true],
["---"]
];
if (!isOSX) {
expectedEntries.push(["#toggle_toolbar-menubar", true]);
}
expectedEntries.push(
["#toggle_PersonalToolbar", true],
["---"],
[".viewCustomizeToolbar", true]
);
checkContextMenu(contextMenu, expectedEntries);
contextMenu.hidePopup();
gCustomizeMode.removeFromArea(lastSpring);
ok(!lastSpring.parentNode, "Spring should have been removed successfully.");
});