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 --- ...40013_registerToolbarNode_calls_registerArea.js | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 browser/components/customizableui/test/browser_940013_registerToolbarNode_calls_registerArea.js (limited to 'browser/components/customizableui/test/browser_940013_registerToolbarNode_calls_registerArea.js') diff --git a/browser/components/customizableui/test/browser_940013_registerToolbarNode_calls_registerArea.js b/browser/components/customizableui/test/browser_940013_registerToolbarNode_calls_registerArea.js new file mode 100644 index 0000000000..c4fa54f782 --- /dev/null +++ b/browser/components/customizableui/test/browser_940013_registerToolbarNode_calls_registerArea.js @@ -0,0 +1,64 @@ +/* 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 kToolbarId = "test-registerToolbarNode-toolbar"; +const kButtonId = "test-registerToolbarNode-button"; +registerCleanupFunction(cleanup); + +// Registering a toolbar without a defaultset attribute should +// wait for the registerArea call +add_task(async function () { + ok( + CustomizableUI.inDefaultState, + "Everything should be in its default state." + ); + let btn = createDummyXULButton(kButtonId); + let toolbar = document.createXULElement("toolbar"); + toolbar.id = kToolbarId; + toolbar.setAttribute("customizable", true); + gNavToolbox.appendChild(toolbar); + CustomizableUI.registerToolbarNode(toolbar); + ok( + !CustomizableUI.areas.includes(kToolbarId), + "Toolbar should not yet have been registered automatically." + ); + CustomizableUI.registerArea(kToolbarId, { defaultPlacements: [kButtonId] }); + ok( + CustomizableUI.areas.includes(kToolbarId), + "Toolbar should have been registered now." + ); + is( + CustomizableUI.getAreaType(kToolbarId), + CustomizableUI.TYPE_TOOLBAR, + "Area should be registered as toolbar" + ); + assertAreaPlacements(kToolbarId, [kButtonId]); + ok( + !CustomizableUI.inDefaultState, + "No longer in default state after toolbar is registered and visible." + ); + CustomizableUI.unregisterArea(kToolbarId, true); + toolbar.remove(); + ok( + CustomizableUI.inDefaultState, + "Everything should be in its default state." + ); + btn.remove(); +}); + +async function cleanup() { + let toolbar = document.getElementById(kToolbarId); + if (toolbar) { + toolbar.remove(); + } + let btn = + document.getElementById(kButtonId) || + gNavToolbox.querySelector("#" + kButtonId); + if (btn) { + btn.remove(); + } + await resetCustomization(); +} -- cgit v1.2.3