|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 const kCustomClass = "acustomclassnoonewilluse"; |
|
8 let tempElement = null; |
|
9 |
|
10 function insertClassNameToMenuChildren(parentMenu) { |
|
11 let el = parentMenu.querySelector("menuitem:first-of-type"); |
|
12 el.classList.add(kCustomClass); |
|
13 tempElement = el; |
|
14 } |
|
15 |
|
16 function checkSubviewButtonClass(menuId, buttonId, subviewId) { |
|
17 return function() { |
|
18 info("Checking for items without the subviewbutton class in " + buttonId + " widget"); |
|
19 let menu = document.getElementById(menuId); |
|
20 insertClassNameToMenuChildren(menu); |
|
21 |
|
22 let placement = CustomizableUI.getPlacementOfWidget(buttonId); |
|
23 let changedPlacement = false; |
|
24 if (!placement || placement.area != CustomizableUI.AREA_PANEL) { |
|
25 CustomizableUI.addWidgetToArea(buttonId, CustomizableUI.AREA_PANEL); |
|
26 changedPlacement = true; |
|
27 } |
|
28 yield PanelUI.show(); |
|
29 |
|
30 let button = document.getElementById(buttonId); |
|
31 button.click(); |
|
32 |
|
33 yield waitForCondition(() => !PanelUI.multiView.hasAttribute("transitioning")); |
|
34 let subview = document.getElementById(subviewId); |
|
35 ok(subview.firstChild, "Subview should have a kid"); |
|
36 let subviewchildren = subview.querySelectorAll("toolbarbutton"); |
|
37 for (let i = 0; i < subviewchildren.length; i++) { |
|
38 let item = subviewchildren[i]; |
|
39 let itemReadable = "Item '" + item.label + "' (classes: " + item.className + ")"; |
|
40 ok(item.classList.contains("subviewbutton"), itemReadable + " should have the subviewbutton class."); |
|
41 if (i == 0) { |
|
42 ok(item.classList.contains(kCustomClass), itemReadable + " should still have its own class, too."); |
|
43 } |
|
44 } |
|
45 |
|
46 let panelHiddenPromise = promisePanelHidden(window); |
|
47 PanelUI.hide(); |
|
48 yield panelHiddenPromise; |
|
49 |
|
50 if (changedPlacement) { |
|
51 CustomizableUI.reset(); |
|
52 } |
|
53 }; |
|
54 } |
|
55 |
|
56 add_task(checkSubviewButtonClass("menuWebDeveloperPopup", "developer-button", "PanelUI-developerItems")); |
|
57 add_task(checkSubviewButtonClass("viewSidebarMenu", "sidebar-button", "PanelUI-sidebarItems")); |
|
58 |
|
59 registerCleanupFunction(function() { |
|
60 tempElement.classList.remove(kCustomClass) |
|
61 tempElement = null; |
|
62 }); |