michael@0: "use strict"; michael@0: michael@0: let overflowPanel = document.getElementById("widget-overflow"); michael@0: michael@0: const isOSX = (Services.appinfo.OS === "Darwin"); michael@0: michael@0: let originalWindowWidth; michael@0: registerCleanupFunction(function() { michael@0: overflowPanel.removeAttribute("animate"); michael@0: window.resizeTo(originalWindowWidth, window.outerHeight); michael@0: }); michael@0: michael@0: // Right-click on an item within the overflow panel should michael@0: // show a context menu with options to move it. michael@0: add_task(function() { michael@0: michael@0: overflowPanel.setAttribute("animate", "false"); michael@0: michael@0: originalWindowWidth = window.outerWidth; michael@0: let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); michael@0: ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar."); michael@0: let oldChildCount = navbar.customizationTarget.childElementCount; michael@0: window.resizeTo(400, window.outerHeight); michael@0: michael@0: yield waitForCondition(() => navbar.hasAttribute("overflowing")); michael@0: ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar."); michael@0: michael@0: let chevron = document.getElementById("nav-bar-overflow-button"); michael@0: let shownPanelPromise = promisePanelElementShown(window, overflowPanel); michael@0: chevron.click(); michael@0: yield shownPanelPromise; michael@0: michael@0: let contextMenu = document.getElementById("toolbar-context-menu"); michael@0: let shownContextPromise = popupShown(contextMenu); michael@0: let homeButton = document.getElementById("home-button"); michael@0: ok(homeButton, "home-button was found"); michael@0: is(homeButton.getAttribute("overflowedItem"), "true", "Home button is overflowing"); michael@0: EventUtils.synthesizeMouse(homeButton, 2, 2, {type: "contextmenu", button: 2}); michael@0: yield shownContextPromise; michael@0: michael@0: is(overflowPanel.state, "open", "The widget overflow panel should still be open."); michael@0: michael@0: let expectedEntries = [ michael@0: [".customize-context-moveToPanel", true], michael@0: [".customize-context-removeFromToolbar", true], michael@0: ["---"] michael@0: ]; michael@0: if (!isOSX) { michael@0: expectedEntries.push(["#toggle_toolbar-menubar", true]); michael@0: } michael@0: expectedEntries.push( michael@0: ["#toggle_PersonalToolbar", true], michael@0: ["---"], michael@0: [".viewCustomizeToolbar", true] michael@0: ); michael@0: checkContextMenu(contextMenu, expectedEntries); michael@0: michael@0: let hiddenContextPromise = popupHidden(contextMenu); michael@0: let hiddenPromise = promisePanelElementHidden(window, overflowPanel); michael@0: let moveToPanel = contextMenu.querySelector(".customize-context-moveToPanel"); michael@0: if (moveToPanel) { michael@0: moveToPanel.click(); michael@0: } michael@0: contextMenu.hidePopup(); michael@0: yield hiddenContextPromise; michael@0: yield hiddenPromise; michael@0: michael@0: let homeButtonPlacement = CustomizableUI.getPlacementOfWidget("home-button"); michael@0: ok(homeButtonPlacement, "Home button should still have a placement"); michael@0: is(homeButtonPlacement && homeButtonPlacement.area, "PanelUI-contents", "Home button should be in the panel now"); michael@0: CustomizableUI.reset(); michael@0: michael@0: // In some cases, it can take a tick for the navbar to overflow again. Wait for it: michael@0: yield waitForCondition(() => navbar.hasAttribute("overflowing")); michael@0: ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar."); michael@0: michael@0: let homeButtonPlacement = CustomizableUI.getPlacementOfWidget("home-button"); michael@0: ok(homeButtonPlacement, "Home button should still have a placement"); michael@0: is(homeButtonPlacement && homeButtonPlacement.area, "nav-bar", "Home button should be back in the navbar now"); michael@0: michael@0: is(homeButton.getAttribute("overflowedItem"), "true", "Home button should still be overflowed"); michael@0: });