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