browser_886323_buildArea_removable_nodes.js (1912B)
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 kButtonId = "test-886323-removable-moved-node"; 8 const kLazyAreaId = "test-886323-lazy-area-for-removability-testing"; 9 10 var gNavBar = document.getElementById(CustomizableUI.AREA_NAVBAR); 11 var gLazyArea; 12 13 // Removable nodes shouldn't be moved by buildArea 14 add_task(async function () { 15 let dummyBtn = createDummyXULButton(kButtonId, "Dummy"); 16 dummyBtn.setAttribute("removable", "true"); 17 CustomizableUI.getCustomizationTarget(gNavBar).appendChild(dummyBtn); 18 let popupSet = document.getElementById("mainPopupSet"); 19 gLazyArea = document.createXULElement("panel"); 20 gLazyArea.id = kLazyAreaId; 21 gLazyArea.hidden = true; 22 popupSet.appendChild(gLazyArea); 23 CustomizableUI.registerArea(kLazyAreaId, { 24 type: CustomizableUI.TYPE_PANEL, 25 defaultPlacements: [], 26 }); 27 CustomizableUI.addWidgetToArea(kButtonId, kLazyAreaId); 28 assertAreaPlacements( 29 kLazyAreaId, 30 [kButtonId], 31 "Placements should have changed because widget is removable." 32 ); 33 let btn = document.getElementById(kButtonId); 34 btn.setAttribute("removable", "false"); 35 gLazyArea._customizationTarget = gLazyArea; 36 CustomizableUI.registerToolbarNode(gLazyArea, []); 37 assertAreaPlacements( 38 kLazyAreaId, 39 [], 40 "Placements should no longer include widget." 41 ); 42 is( 43 btn.parentNode.id, 44 CustomizableUI.getCustomizationTarget(gNavBar).id, 45 "Button shouldn't actually have moved as it's not removable" 46 ); 47 btn = document.getElementById(kButtonId); 48 if (btn) { 49 btn.remove(); 50 } 51 CustomizableUI.removeWidgetFromArea(kButtonId); 52 CustomizableUI.unregisterArea(kLazyAreaId); 53 gLazyArea.remove(); 54 }); 55 56 add_task(async function asyncCleanup() { 57 await resetCustomization(); 58 });