1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_884402_customize_from_overflow.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,82 @@ 1.4 +"use strict"; 1.5 + 1.6 +let overflowPanel = document.getElementById("widget-overflow"); 1.7 + 1.8 +const isOSX = (Services.appinfo.OS === "Darwin"); 1.9 + 1.10 +let originalWindowWidth; 1.11 +registerCleanupFunction(function() { 1.12 + overflowPanel.removeAttribute("animate"); 1.13 + window.resizeTo(originalWindowWidth, window.outerHeight); 1.14 +}); 1.15 + 1.16 +// Right-click on an item within the overflow panel should 1.17 +// show a context menu with options to move it. 1.18 +add_task(function() { 1.19 + 1.20 + overflowPanel.setAttribute("animate", "false"); 1.21 + 1.22 + originalWindowWidth = window.outerWidth; 1.23 + let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); 1.24 + ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar."); 1.25 + let oldChildCount = navbar.customizationTarget.childElementCount; 1.26 + window.resizeTo(400, window.outerHeight); 1.27 + 1.28 + yield waitForCondition(() => navbar.hasAttribute("overflowing")); 1.29 + ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar."); 1.30 + 1.31 + let chevron = document.getElementById("nav-bar-overflow-button"); 1.32 + let shownPanelPromise = promisePanelElementShown(window, overflowPanel); 1.33 + chevron.click(); 1.34 + yield shownPanelPromise; 1.35 + 1.36 + let contextMenu = document.getElementById("toolbar-context-menu"); 1.37 + let shownContextPromise = popupShown(contextMenu); 1.38 + let homeButton = document.getElementById("home-button"); 1.39 + ok(homeButton, "home-button was found"); 1.40 + is(homeButton.getAttribute("overflowedItem"), "true", "Home button is overflowing"); 1.41 + EventUtils.synthesizeMouse(homeButton, 2, 2, {type: "contextmenu", button: 2}); 1.42 + yield shownContextPromise; 1.43 + 1.44 + is(overflowPanel.state, "open", "The widget overflow panel should still be open."); 1.45 + 1.46 + let expectedEntries = [ 1.47 + [".customize-context-moveToPanel", true], 1.48 + [".customize-context-removeFromToolbar", true], 1.49 + ["---"] 1.50 + ]; 1.51 + if (!isOSX) { 1.52 + expectedEntries.push(["#toggle_toolbar-menubar", true]); 1.53 + } 1.54 + expectedEntries.push( 1.55 + ["#toggle_PersonalToolbar", true], 1.56 + ["---"], 1.57 + [".viewCustomizeToolbar", true] 1.58 + ); 1.59 + checkContextMenu(contextMenu, expectedEntries); 1.60 + 1.61 + let hiddenContextPromise = popupHidden(contextMenu); 1.62 + let hiddenPromise = promisePanelElementHidden(window, overflowPanel); 1.63 + let moveToPanel = contextMenu.querySelector(".customize-context-moveToPanel"); 1.64 + if (moveToPanel) { 1.65 + moveToPanel.click(); 1.66 + } 1.67 + contextMenu.hidePopup(); 1.68 + yield hiddenContextPromise; 1.69 + yield hiddenPromise; 1.70 + 1.71 + let homeButtonPlacement = CustomizableUI.getPlacementOfWidget("home-button"); 1.72 + ok(homeButtonPlacement, "Home button should still have a placement"); 1.73 + is(homeButtonPlacement && homeButtonPlacement.area, "PanelUI-contents", "Home button should be in the panel now"); 1.74 + CustomizableUI.reset(); 1.75 + 1.76 + // In some cases, it can take a tick for the navbar to overflow again. Wait for it: 1.77 + yield waitForCondition(() => navbar.hasAttribute("overflowing")); 1.78 + ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar."); 1.79 + 1.80 + let homeButtonPlacement = CustomizableUI.getPlacementOfWidget("home-button"); 1.81 + ok(homeButtonPlacement, "Home button should still have a placement"); 1.82 + is(homeButtonPlacement && homeButtonPlacement.area, "nav-bar", "Home button should be back in the navbar now"); 1.83 + 1.84 + is(homeButton.getAttribute("overflowedItem"), "true", "Home button should still be overflowed"); 1.85 +});