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 --- ...ser_996364_registerArea_different_properties.js | 142 +++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 browser/components/customizableui/test/browser_996364_registerArea_different_properties.js (limited to 'browser/components/customizableui/test/browser_996364_registerArea_different_properties.js') diff --git a/browser/components/customizableui/test/browser_996364_registerArea_different_properties.js b/browser/components/customizableui/test/browser_996364_registerArea_different_properties.js new file mode 100644 index 0000000000..7d8ea59150 --- /dev/null +++ b/browser/components/customizableui/test/browser_996364_registerArea_different_properties.js @@ -0,0 +1,142 @@ +/* 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"; + +// Calling CustomizableUI.registerArea twice with no +// properties should not throw an exception. +add_task(function () { + try { + CustomizableUI.registerArea("area-996364", {}); + CustomizableUI.registerArea("area-996364", {}); + } catch (ex) { + ok(false, ex.message); + } + + CustomizableUI.unregisterArea("area-996364", true); +}); + +add_task(function () { + let exceptionThrown = false; + try { + CustomizableUI.registerArea("area-996364-2", { + type: CustomizableUI.TYPE_TOOLBAR, + defaultCollapsed: "false", + }); + } catch (ex) { + exceptionThrown = true; + } + ok( + exceptionThrown, + "defaultCollapsed is not allowed as an external property" + ); + + // No need to unregister the area because registration fails. +}); + +add_task(function () { + let exceptionThrown; + try { + CustomizableUI.registerArea("area-996364-3", { + type: CustomizableUI.TYPE_TOOLBAR, + }); + CustomizableUI.registerArea("area-996364-3", { + type: CustomizableUI.TYPE_PANEL, + }); + } catch (ex) { + exceptionThrown = ex; + } + ok( + exceptionThrown, + "Exception expected, an area cannot change types: " + + (exceptionThrown ? exceptionThrown : "[no exception]") + ); + + CustomizableUI.unregisterArea("area-996364-3", true); +}); + +add_task(function () { + let exceptionThrown; + try { + CustomizableUI.registerArea("area-996364-4", { + type: CustomizableUI.TYPE_PANEL, + }); + CustomizableUI.registerArea("area-996364-4", { + type: CustomizableUI.TYPE_TOOLBAR, + }); + } catch (ex) { + exceptionThrown = ex; + } + ok( + exceptionThrown, + "Exception expected, an area cannot change types: " + + (exceptionThrown ? exceptionThrown : "[no exception]") + ); + + CustomizableUI.unregisterArea("area-996364-4", true); +}); + +add_task(function () { + let exceptionThrown; + try { + CustomizableUI.registerArea("area-996899-1", { + anchor: "PanelUI-menu-button", + type: CustomizableUI.TYPE_PANEL, + defaultPlacements: [], + }); + CustomizableUI.registerArea("area-996899-1", { + anchor: "home-button", + type: CustomizableUI.TYPE_PANEL, + defaultPlacements: [], + }); + } catch (ex) { + exceptionThrown = ex; + } + ok( + !exceptionThrown, + "Changing anchors shouldn't throw an exception: " + + (exceptionThrown ? exceptionThrown : "[no exception]") + ); + CustomizableUI.unregisterArea("area-996899-1", true); +}); + +add_task(function () { + let exceptionThrown; + try { + CustomizableUI.registerArea("area-996899-2", { + anchor: "PanelUI-menu-button", + type: CustomizableUI.TYPE_PANEL, + defaultPlacements: [], + }); + CustomizableUI.registerArea("area-996899-2", { + anchor: "PanelUI-menu-button", + type: CustomizableUI.TYPE_PANEL, + defaultPlacements: ["new-window-button"], + }); + } catch (ex) { + exceptionThrown = ex; + } + ok( + !exceptionThrown, + "Changing defaultPlacements shouldn't throw an exception: " + + (exceptionThrown ? exceptionThrown : "[no exception]") + ); + CustomizableUI.unregisterArea("area-996899-2", true); +}); + +add_task(function () { + let exceptionThrown; + try { + CustomizableUI.registerArea("area-996899-4", { overflowable: true }); + CustomizableUI.registerArea("area-996899-4", { overflowable: false }); + } catch (ex) { + exceptionThrown = ex; + } + ok( + exceptionThrown, + "Changing 'overflowable' should throw an exception: " + + (exceptionThrown ? exceptionThrown : "[no exception]") + ); + CustomizableUI.unregisterArea("area-996899-4", true); +}); -- cgit v1.2.3