From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../browser_886323_buildArea_removable_nodes.js | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 browser/components/customizableui/test/browser_886323_buildArea_removable_nodes.js (limited to 'browser/components/customizableui/test/browser_886323_buildArea_removable_nodes.js') diff --git a/browser/components/customizableui/test/browser_886323_buildArea_removable_nodes.js b/browser/components/customizableui/test/browser_886323_buildArea_removable_nodes.js new file mode 100644 index 0000000000..99968a8266 --- /dev/null +++ b/browser/components/customizableui/test/browser_886323_buildArea_removable_nodes.js @@ -0,0 +1,58 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const kButtonId = "test-886323-removable-moved-node"; +const kLazyAreaId = "test-886323-lazy-area-for-removability-testing"; + +var gNavBar = document.getElementById(CustomizableUI.AREA_NAVBAR); +var gLazyArea; + +// Removable nodes shouldn't be moved by buildArea +add_task(async function () { + let dummyBtn = createDummyXULButton(kButtonId, "Dummy"); + dummyBtn.setAttribute("removable", "true"); + CustomizableUI.getCustomizationTarget(gNavBar).appendChild(dummyBtn); + let popupSet = document.getElementById("mainPopupSet"); + gLazyArea = document.createXULElement("panel"); + gLazyArea.id = kLazyAreaId; + gLazyArea.hidden = true; + popupSet.appendChild(gLazyArea); + CustomizableUI.registerArea(kLazyAreaId, { + type: CustomizableUI.TYPE_PANEL, + defaultPlacements: [], + }); + CustomizableUI.addWidgetToArea(kButtonId, kLazyAreaId); + assertAreaPlacements( + kLazyAreaId, + [kButtonId], + "Placements should have changed because widget is removable." + ); + let btn = document.getElementById(kButtonId); + btn.setAttribute("removable", "false"); + gLazyArea._customizationTarget = gLazyArea; + CustomizableUI.registerToolbarNode(gLazyArea, []); + assertAreaPlacements( + kLazyAreaId, + [], + "Placements should no longer include widget." + ); + is( + btn.parentNode.id, + CustomizableUI.getCustomizationTarget(gNavBar).id, + "Button shouldn't actually have moved as it's not removable" + ); + btn = document.getElementById(kButtonId); + if (btn) { + btn.remove(); + } + CustomizableUI.removeWidgetFromArea(kButtonId); + CustomizableUI.unregisterArea(kLazyAreaId); + gLazyArea.remove(); +}); + +add_task(async function asyncCleanup() { + await resetCustomization(); +}); -- cgit v1.2.3