|
1 "use strict"; |
|
2 |
|
3 let overflowPanel = document.getElementById("widget-overflow"); |
|
4 |
|
5 const isOSX = (Services.appinfo.OS === "Darwin"); |
|
6 |
|
7 let originalWindowWidth; |
|
8 registerCleanupFunction(function() { |
|
9 overflowPanel.removeAttribute("animate"); |
|
10 window.resizeTo(originalWindowWidth, window.outerHeight); |
|
11 }); |
|
12 |
|
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() { |
|
16 |
|
17 overflowPanel.setAttribute("animate", "false"); |
|
18 |
|
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); |
|
24 |
|
25 yield waitForCondition(() => navbar.hasAttribute("overflowing")); |
|
26 ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar."); |
|
27 |
|
28 let chevron = document.getElementById("nav-bar-overflow-button"); |
|
29 let shownPanelPromise = promisePanelElementShown(window, overflowPanel); |
|
30 chevron.click(); |
|
31 yield shownPanelPromise; |
|
32 |
|
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; |
|
40 |
|
41 is(overflowPanel.state, "open", "The widget overflow panel should still be open."); |
|
42 |
|
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); |
|
57 |
|
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; |
|
67 |
|
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(); |
|
72 |
|
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."); |
|
76 |
|
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"); |
|
80 |
|
81 is(homeButton.getAttribute("overflowedItem"), "true", "Home button should still be overflowed"); |
|
82 }); |