browser/components/customizableui/test/browser_989751_subviewbutton_class.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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

mercurial