1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_989751_subviewbutton_class.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +const kCustomClass = "acustomclassnoonewilluse"; 1.11 +let tempElement = null; 1.12 + 1.13 +function insertClassNameToMenuChildren(parentMenu) { 1.14 + let el = parentMenu.querySelector("menuitem:first-of-type"); 1.15 + el.classList.add(kCustomClass); 1.16 + tempElement = el; 1.17 +} 1.18 + 1.19 +function checkSubviewButtonClass(menuId, buttonId, subviewId) { 1.20 + return function() { 1.21 + info("Checking for items without the subviewbutton class in " + buttonId + " widget"); 1.22 + let menu = document.getElementById(menuId); 1.23 + insertClassNameToMenuChildren(menu); 1.24 + 1.25 + let placement = CustomizableUI.getPlacementOfWidget(buttonId); 1.26 + let changedPlacement = false; 1.27 + if (!placement || placement.area != CustomizableUI.AREA_PANEL) { 1.28 + CustomizableUI.addWidgetToArea(buttonId, CustomizableUI.AREA_PANEL); 1.29 + changedPlacement = true; 1.30 + } 1.31 + yield PanelUI.show(); 1.32 + 1.33 + let button = document.getElementById(buttonId); 1.34 + button.click(); 1.35 + 1.36 + yield waitForCondition(() => !PanelUI.multiView.hasAttribute("transitioning")); 1.37 + let subview = document.getElementById(subviewId); 1.38 + ok(subview.firstChild, "Subview should have a kid"); 1.39 + let subviewchildren = subview.querySelectorAll("toolbarbutton"); 1.40 + for (let i = 0; i < subviewchildren.length; i++) { 1.41 + let item = subviewchildren[i]; 1.42 + let itemReadable = "Item '" + item.label + "' (classes: " + item.className + ")"; 1.43 + ok(item.classList.contains("subviewbutton"), itemReadable + " should have the subviewbutton class."); 1.44 + if (i == 0) { 1.45 + ok(item.classList.contains(kCustomClass), itemReadable + " should still have its own class, too."); 1.46 + } 1.47 + } 1.48 + 1.49 + let panelHiddenPromise = promisePanelHidden(window); 1.50 + PanelUI.hide(); 1.51 + yield panelHiddenPromise; 1.52 + 1.53 + if (changedPlacement) { 1.54 + CustomizableUI.reset(); 1.55 + } 1.56 + }; 1.57 +} 1.58 + 1.59 +add_task(checkSubviewButtonClass("menuWebDeveloperPopup", "developer-button", "PanelUI-developerItems")); 1.60 +add_task(checkSubviewButtonClass("viewSidebarMenu", "sidebar-button", "PanelUI-sidebarItems")); 1.61 + 1.62 +registerCleanupFunction(function() { 1.63 + tempElement.classList.remove(kCustomClass) 1.64 + tempElement = null; 1.65 +});