diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/components/customizableui/test/browser_982656_restore_defaults_builtin_widgets.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/components/customizableui/test/browser_982656_restore_defaults_builtin_widgets.js | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/browser/components/customizableui/test/browser_982656_restore_defaults_builtin_widgets.js b/browser/components/customizableui/test/browser_982656_restore_defaults_builtin_widgets.js new file mode 100644 index 0000000000..20314d6790 --- /dev/null +++ b/browser/components/customizableui/test/browser_982656_restore_defaults_builtin_widgets.js @@ -0,0 +1,82 @@ +/* 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"; + +// Restoring default should not place addon widgets back in the toolbar +add_task(async function () { + ok(CustomizableUI.inDefaultState, "Default state to begin"); + + const kWidgetId = + "bug982656-add-on-widget-should-not-restore-to-default-area"; + let widgetSpec = { + id: kWidgetId, + defaultArea: CustomizableUI.AREA_NAVBAR, + }; + CustomizableUI.createWidget(widgetSpec); + + ok(!CustomizableUI.inDefaultState, "Not in default state after widget added"); + is( + CustomizableUI.getPlacementOfWidget(kWidgetId).area, + CustomizableUI.AREA_NAVBAR, + "Widget should be in navbar" + ); + + await resetCustomization(); + + ok(CustomizableUI.inDefaultState, "Back in default state after reset"); + is( + CustomizableUI.getPlacementOfWidget(kWidgetId), + null, + "Widget now in palette" + ); + CustomizableUI.destroyWidget(kWidgetId); +}); + +// resetCustomization shouldn't move 3rd party widgets out of custom toolbars +add_task(async function () { + const kToolbarId = "bug982656-toolbar-with-defaultset"; + const kWidgetId = + "bug982656-add-on-widget-should-restore-to-default-area-when-area-is-not-builtin"; + ok( + CustomizableUI.inDefaultState, + "Everything should be in its default state." + ); + let toolbar = createToolbarWithPlacements(kToolbarId); + ok(CustomizableUI.areas.includes(kToolbarId), "Toolbar has been registered."); + is( + CustomizableUI.getAreaType(kToolbarId), + CustomizableUI.TYPE_TOOLBAR, + "Area should be registered as toolbar" + ); + + let widgetSpec = { + id: kWidgetId, + defaultArea: kToolbarId, + }; + CustomizableUI.createWidget(widgetSpec); + + ok( + !CustomizableUI.inDefaultState, + "No longer in default state after toolbar is registered and visible." + ); + is( + CustomizableUI.getPlacementOfWidget(kWidgetId).area, + kToolbarId, + "Widget should be in custom toolbar" + ); + + await resetCustomization(); + ok(CustomizableUI.inDefaultState, "Back in default state after reset"); + is( + CustomizableUI.getPlacementOfWidget(kWidgetId).area, + kToolbarId, + "Widget still in custom toolbar" + ); + ok(toolbar.collapsed, "Custom toolbar should be collapsed after reset"); + + toolbar.remove(); + CustomizableUI.destroyWidget(kWidgetId); + CustomizableUI.unregisterArea(kToolbarId); +}); |