1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_886323_buildArea_removable_nodes.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 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 kButtonId = "test-886323-removable-moved-node"; 1.11 +const kLazyAreaId = "test-886323-lazy-area-for-removability-testing"; 1.12 + 1.13 +let gNavBar = document.getElementById(CustomizableUI.AREA_NAVBAR); 1.14 +let gLazyArea; 1.15 + 1.16 +// Removable nodes shouldn't be moved by buildArea 1.17 +add_task(function() { 1.18 + let dummyBtn = createDummyXULButton(kButtonId, "Dummy"); 1.19 + dummyBtn.setAttribute("removable", "true"); 1.20 + gNavBar.customizationTarget.appendChild(dummyBtn); 1.21 + let popupSet = document.getElementById("mainPopupSet"); 1.22 + gLazyArea = document.createElementNS(kNSXUL, "panel"); 1.23 + gLazyArea.id = kLazyAreaId; 1.24 + gLazyArea.setAttribute("hidden", "true"); 1.25 + popupSet.appendChild(gLazyArea); 1.26 + CustomizableUI.registerArea(kLazyAreaId, { 1.27 + type: CustomizableUI.TYPE_MENU_PANEL, 1.28 + defaultPlacements: [] 1.29 + }); 1.30 + CustomizableUI.addWidgetToArea(kButtonId, kLazyAreaId); 1.31 + assertAreaPlacements(kLazyAreaId, [kButtonId], 1.32 + "Placements should have changed because widget is removable."); 1.33 + let btn = document.getElementById(kButtonId); 1.34 + btn.setAttribute("removable", "false"); 1.35 + gLazyArea.customizationTarget = gLazyArea; 1.36 + CustomizableUI.registerToolbarNode(gLazyArea, []); 1.37 + assertAreaPlacements(kLazyAreaId, [], "Placements should no longer include widget."); 1.38 + is(btn.parentNode.id, gNavBar.customizationTarget.id, 1.39 + "Button shouldn't actually have moved as it's not removable"); 1.40 + let btn = document.getElementById(kButtonId); 1.41 + if (btn) btn.remove(); 1.42 + CustomizableUI.removeWidgetFromArea(kButtonId); 1.43 + CustomizableUI.unregisterArea(kLazyAreaId); 1.44 + gLazyArea.remove(); 1.45 +}); 1.46 + 1.47 +add_task(function asyncCleanup() { 1.48 + yield resetCustomization(); 1.49 +});