Wed, 31 Dec 2014 13:27:57 +0100
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 kButtonId = "test-886323-removable-moved-node"; |
michael@0 | 8 | const kLazyAreaId = "test-886323-lazy-area-for-removability-testing"; |
michael@0 | 9 | |
michael@0 | 10 | let gNavBar = document.getElementById(CustomizableUI.AREA_NAVBAR); |
michael@0 | 11 | let gLazyArea; |
michael@0 | 12 | |
michael@0 | 13 | // Removable nodes shouldn't be moved by buildArea |
michael@0 | 14 | add_task(function() { |
michael@0 | 15 | let dummyBtn = createDummyXULButton(kButtonId, "Dummy"); |
michael@0 | 16 | dummyBtn.setAttribute("removable", "true"); |
michael@0 | 17 | gNavBar.customizationTarget.appendChild(dummyBtn); |
michael@0 | 18 | let popupSet = document.getElementById("mainPopupSet"); |
michael@0 | 19 | gLazyArea = document.createElementNS(kNSXUL, "panel"); |
michael@0 | 20 | gLazyArea.id = kLazyAreaId; |
michael@0 | 21 | gLazyArea.setAttribute("hidden", "true"); |
michael@0 | 22 | popupSet.appendChild(gLazyArea); |
michael@0 | 23 | CustomizableUI.registerArea(kLazyAreaId, { |
michael@0 | 24 | type: CustomizableUI.TYPE_MENU_PANEL, |
michael@0 | 25 | defaultPlacements: [] |
michael@0 | 26 | }); |
michael@0 | 27 | CustomizableUI.addWidgetToArea(kButtonId, kLazyAreaId); |
michael@0 | 28 | assertAreaPlacements(kLazyAreaId, [kButtonId], |
michael@0 | 29 | "Placements should have changed because widget is removable."); |
michael@0 | 30 | let btn = document.getElementById(kButtonId); |
michael@0 | 31 | btn.setAttribute("removable", "false"); |
michael@0 | 32 | gLazyArea.customizationTarget = gLazyArea; |
michael@0 | 33 | CustomizableUI.registerToolbarNode(gLazyArea, []); |
michael@0 | 34 | assertAreaPlacements(kLazyAreaId, [], "Placements should no longer include widget."); |
michael@0 | 35 | is(btn.parentNode.id, gNavBar.customizationTarget.id, |
michael@0 | 36 | "Button shouldn't actually have moved as it's not removable"); |
michael@0 | 37 | let btn = document.getElementById(kButtonId); |
michael@0 | 38 | if (btn) btn.remove(); |
michael@0 | 39 | CustomizableUI.removeWidgetFromArea(kButtonId); |
michael@0 | 40 | CustomizableUI.unregisterArea(kLazyAreaId); |
michael@0 | 41 | gLazyArea.remove(); |
michael@0 | 42 | }); |
michael@0 | 43 | |
michael@0 | 44 | add_task(function asyncCleanup() { |
michael@0 | 45 | yield resetCustomization(); |
michael@0 | 46 | }); |