Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | "use strict"; |
michael@0 | 2 | |
michael@0 | 3 | let overflowPanel = document.getElementById("widget-overflow"); |
michael@0 | 4 | |
michael@0 | 5 | const isOSX = (Services.appinfo.OS === "Darwin"); |
michael@0 | 6 | |
michael@0 | 7 | let originalWindowWidth; |
michael@0 | 8 | registerCleanupFunction(function() { |
michael@0 | 9 | overflowPanel.removeAttribute("animate"); |
michael@0 | 10 | window.resizeTo(originalWindowWidth, window.outerHeight); |
michael@0 | 11 | }); |
michael@0 | 12 | |
michael@0 | 13 | // Right-click on an item within the overflow panel should |
michael@0 | 14 | // show a context menu with options to move it. |
michael@0 | 15 | add_task(function() { |
michael@0 | 16 | |
michael@0 | 17 | overflowPanel.setAttribute("animate", "false"); |
michael@0 | 18 | |
michael@0 | 19 | originalWindowWidth = window.outerWidth; |
michael@0 | 20 | let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); |
michael@0 | 21 | ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar."); |
michael@0 | 22 | let oldChildCount = navbar.customizationTarget.childElementCount; |
michael@0 | 23 | window.resizeTo(400, window.outerHeight); |
michael@0 | 24 | |
michael@0 | 25 | yield waitForCondition(() => navbar.hasAttribute("overflowing")); |
michael@0 | 26 | ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar."); |
michael@0 | 27 | |
michael@0 | 28 | let chevron = document.getElementById("nav-bar-overflow-button"); |
michael@0 | 29 | let shownPanelPromise = promisePanelElementShown(window, overflowPanel); |
michael@0 | 30 | chevron.click(); |
michael@0 | 31 | yield shownPanelPromise; |
michael@0 | 32 | |
michael@0 | 33 | let contextMenu = document.getElementById("toolbar-context-menu"); |
michael@0 | 34 | let shownContextPromise = popupShown(contextMenu); |
michael@0 | 35 | let homeButton = document.getElementById("home-button"); |
michael@0 | 36 | ok(homeButton, "home-button was found"); |
michael@0 | 37 | is(homeButton.getAttribute("overflowedItem"), "true", "Home button is overflowing"); |
michael@0 | 38 | EventUtils.synthesizeMouse(homeButton, 2, 2, {type: "contextmenu", button: 2}); |
michael@0 | 39 | yield shownContextPromise; |
michael@0 | 40 | |
michael@0 | 41 | is(overflowPanel.state, "open", "The widget overflow panel should still be open."); |
michael@0 | 42 | |
michael@0 | 43 | let expectedEntries = [ |
michael@0 | 44 | [".customize-context-moveToPanel", true], |
michael@0 | 45 | [".customize-context-removeFromToolbar", true], |
michael@0 | 46 | ["---"] |
michael@0 | 47 | ]; |
michael@0 | 48 | if (!isOSX) { |
michael@0 | 49 | expectedEntries.push(["#toggle_toolbar-menubar", true]); |
michael@0 | 50 | } |
michael@0 | 51 | expectedEntries.push( |
michael@0 | 52 | ["#toggle_PersonalToolbar", true], |
michael@0 | 53 | ["---"], |
michael@0 | 54 | [".viewCustomizeToolbar", true] |
michael@0 | 55 | ); |
michael@0 | 56 | checkContextMenu(contextMenu, expectedEntries); |
michael@0 | 57 | |
michael@0 | 58 | let hiddenContextPromise = popupHidden(contextMenu); |
michael@0 | 59 | let hiddenPromise = promisePanelElementHidden(window, overflowPanel); |
michael@0 | 60 | let moveToPanel = contextMenu.querySelector(".customize-context-moveToPanel"); |
michael@0 | 61 | if (moveToPanel) { |
michael@0 | 62 | moveToPanel.click(); |
michael@0 | 63 | } |
michael@0 | 64 | contextMenu.hidePopup(); |
michael@0 | 65 | yield hiddenContextPromise; |
michael@0 | 66 | yield hiddenPromise; |
michael@0 | 67 | |
michael@0 | 68 | let homeButtonPlacement = CustomizableUI.getPlacementOfWidget("home-button"); |
michael@0 | 69 | ok(homeButtonPlacement, "Home button should still have a placement"); |
michael@0 | 70 | is(homeButtonPlacement && homeButtonPlacement.area, "PanelUI-contents", "Home button should be in the panel now"); |
michael@0 | 71 | CustomizableUI.reset(); |
michael@0 | 72 | |
michael@0 | 73 | // In some cases, it can take a tick for the navbar to overflow again. Wait for it: |
michael@0 | 74 | yield waitForCondition(() => navbar.hasAttribute("overflowing")); |
michael@0 | 75 | ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar."); |
michael@0 | 76 | |
michael@0 | 77 | let homeButtonPlacement = CustomizableUI.getPlacementOfWidget("home-button"); |
michael@0 | 78 | ok(homeButtonPlacement, "Home button should still have a placement"); |
michael@0 | 79 | is(homeButtonPlacement && homeButtonPlacement.area, "nav-bar", "Home button should be back in the navbar now"); |
michael@0 | 80 | |
michael@0 | 81 | is(homeButton.getAttribute("overflowedItem"), "true", "Home button should still be overflowed"); |
michael@0 | 82 | }); |