michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: // Calling CustomizableUI.registerArea twice with no michael@0: // properties should not throw an exception. michael@0: add_task(function() { michael@0: try { michael@0: CustomizableUI.registerArea("area-996364", {}); michael@0: CustomizableUI.registerArea("area-996364", {}); michael@0: } catch (ex) { michael@0: ok(false, ex.message); michael@0: } michael@0: michael@0: CustomizableUI.unregisterArea("area-996364", true); michael@0: }); michael@0: michael@0: add_task(function() { michael@0: let exceptionThrown = false; michael@0: try { michael@0: CustomizableUI.registerArea("area-996364-2", {type: CustomizableUI.TYPE_TOOLBAR, defaultCollapsed: "false"}); michael@0: } catch (ex) { michael@0: exceptionThrown = true; michael@0: } michael@0: ok(exceptionThrown, "defaultCollapsed is not allowed as an external property"); michael@0: michael@0: // No need to unregister the area because registration fails. michael@0: }); michael@0: michael@0: add_task(function() { michael@0: let exceptionThrown; michael@0: try { michael@0: CustomizableUI.registerArea("area-996364-3", {type: CustomizableUI.TYPE_TOOLBAR}); michael@0: CustomizableUI.registerArea("area-996364-3", {type: CustomizableUI.TYPE_MENU_PANEL}); michael@0: } catch (ex) { michael@0: exceptionThrown = ex; michael@0: } michael@0: ok(exceptionThrown, "Exception expected, an area cannot change types: " + (exceptionThrown ? exceptionThrown : "[no exception]")); michael@0: michael@0: CustomizableUI.unregisterArea("area-996364-3", true); michael@0: }); michael@0: michael@0: add_task(function() { michael@0: let exceptionThrown; michael@0: try { michael@0: CustomizableUI.registerArea("area-996364-4", {type: CustomizableUI.TYPE_MENU_PANEL}); michael@0: CustomizableUI.registerArea("area-996364-4", {type: CustomizableUI.TYPE_TOOLBAR}); michael@0: } catch (ex) { michael@0: exceptionThrown = ex; michael@0: } michael@0: ok(exceptionThrown, "Exception expected, an area cannot change types: " + (exceptionThrown ? exceptionThrown : "[no exception]")); michael@0: michael@0: CustomizableUI.unregisterArea("area-996364-4", true); michael@0: }); michael@0: michael@0: add_task(function() { michael@0: let exceptionThrown; michael@0: try { michael@0: CustomizableUI.registerArea("area-996899-1", { anchor: "PanelUI-menu-button", michael@0: type: CustomizableUI.TYPE_MENU_PANEL, michael@0: defaultPlacements: [] }); michael@0: CustomizableUI.registerArea("area-996899-1", { anchor: "home-button", michael@0: type: CustomizableUI.TYPE_MENU_PANEL, michael@0: defaultPlacements: [] }); michael@0: } catch (ex) { michael@0: exceptionThrown = ex; michael@0: } michael@0: ok(!exceptionThrown, "Changing anchors shouldn't throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); michael@0: CustomizableUI.unregisterArea("area-996899-1", true); michael@0: }); michael@0: michael@0: add_task(function() { michael@0: let exceptionThrown; michael@0: try { michael@0: CustomizableUI.registerArea("area-996899-2", { anchor: "PanelUI-menu-button", michael@0: type: CustomizableUI.TYPE_MENU_PANEL, michael@0: defaultPlacements: [] }); michael@0: CustomizableUI.registerArea("area-996899-2", { anchor: "PanelUI-menu-button", michael@0: type: CustomizableUI.TYPE_MENU_PANEL, michael@0: defaultPlacements: ["feed-button"] }); michael@0: } catch (ex) { michael@0: exceptionThrown = ex; michael@0: } michael@0: ok(!exceptionThrown, "Changing defaultPlacements shouldn't throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); michael@0: CustomizableUI.unregisterArea("area-996899-2", true); michael@0: }); michael@0: michael@0: add_task(function() { michael@0: let exceptionThrown; michael@0: try { michael@0: CustomizableUI.registerArea("area-996899-3", { legacy: true }); michael@0: CustomizableUI.registerArea("area-996899-3", { legacy: false }); michael@0: } catch (ex) { michael@0: exceptionThrown = ex; michael@0: } michael@0: ok(exceptionThrown, "Changing 'legacy' should throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); michael@0: CustomizableUI.unregisterArea("area-996899-3", true); michael@0: }); michael@0: michael@0: add_task(function() { michael@0: let exceptionThrown; michael@0: try { michael@0: CustomizableUI.registerArea("area-996899-4", { overflowable: true }); michael@0: CustomizableUI.registerArea("area-996899-4", { overflowable: false }); michael@0: } catch (ex) { michael@0: exceptionThrown = ex; michael@0: } michael@0: ok(exceptionThrown, "Changing 'overflowable' should throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); michael@0: CustomizableUI.unregisterArea("area-996899-4", true); michael@0: });