michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: const kButtonId = "test-886323-removable-moved-node"; michael@0: const kLazyAreaId = "test-886323-lazy-area-for-removability-testing"; michael@0: michael@0: let gNavBar = document.getElementById(CustomizableUI.AREA_NAVBAR); michael@0: let gLazyArea; michael@0: michael@0: // Removable nodes shouldn't be moved by buildArea michael@0: add_task(function() { michael@0: let dummyBtn = createDummyXULButton(kButtonId, "Dummy"); michael@0: dummyBtn.setAttribute("removable", "true"); michael@0: gNavBar.customizationTarget.appendChild(dummyBtn); michael@0: let popupSet = document.getElementById("mainPopupSet"); michael@0: gLazyArea = document.createElementNS(kNSXUL, "panel"); michael@0: gLazyArea.id = kLazyAreaId; michael@0: gLazyArea.setAttribute("hidden", "true"); michael@0: popupSet.appendChild(gLazyArea); michael@0: CustomizableUI.registerArea(kLazyAreaId, { michael@0: type: CustomizableUI.TYPE_MENU_PANEL, michael@0: defaultPlacements: [] michael@0: }); michael@0: CustomizableUI.addWidgetToArea(kButtonId, kLazyAreaId); michael@0: assertAreaPlacements(kLazyAreaId, [kButtonId], michael@0: "Placements should have changed because widget is removable."); michael@0: let btn = document.getElementById(kButtonId); michael@0: btn.setAttribute("removable", "false"); michael@0: gLazyArea.customizationTarget = gLazyArea; michael@0: CustomizableUI.registerToolbarNode(gLazyArea, []); michael@0: assertAreaPlacements(kLazyAreaId, [], "Placements should no longer include widget."); michael@0: is(btn.parentNode.id, gNavBar.customizationTarget.id, michael@0: "Button shouldn't actually have moved as it's not removable"); michael@0: let btn = document.getElementById(kButtonId); michael@0: if (btn) btn.remove(); michael@0: CustomizableUI.removeWidgetFromArea(kButtonId); michael@0: CustomizableUI.unregisterArea(kLazyAreaId); michael@0: gLazyArea.remove(); michael@0: }); michael@0: michael@0: add_task(function asyncCleanup() { michael@0: yield resetCustomization(); michael@0: });