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: registerCleanupFunction(removeCustomToolbars); michael@0: michael@0: // Sanity checks michael@0: add_task(function sanityChecks() { michael@0: SimpleTest.doesThrow(function() CustomizableUI.registerArea("@foo"), michael@0: "Registering areas with an invalid ID should throw."); michael@0: michael@0: SimpleTest.doesThrow(function() CustomizableUI.registerArea([]), michael@0: "Registering areas with an invalid ID should throw."); michael@0: michael@0: SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("@foo"), michael@0: "Unregistering areas with an invalid ID should throw."); michael@0: michael@0: SimpleTest.doesThrow(function() CustomizableUI.unregisterArea([]), michael@0: "Unregistering areas with an invalid ID should throw."); michael@0: michael@0: SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("unknown"), michael@0: "Unregistering an area that's not registered should throw."); michael@0: }); michael@0: michael@0: // Check areas are loaded with their default placements. michael@0: add_task(function checkLoadedAres() { michael@0: ok(CustomizableUI.inDefaultState, "Everything should be in its default state."); michael@0: }); michael@0: michael@0: // Check registering and unregistering a new area. michael@0: add_task(function checkRegisteringAndUnregistering() { michael@0: const kToolbarId = "test-registration-toolbar"; michael@0: const kButtonId = "test-registration-button"; michael@0: createDummyXULButton(kButtonId); michael@0: createToolbarWithPlacements(kToolbarId, ["spring", kButtonId, "spring"]); michael@0: assertAreaPlacements(kToolbarId, michael@0: [/customizableui-special-spring\d+/, michael@0: kButtonId, michael@0: /customizableui-special-spring\d+/]); michael@0: ok(!CustomizableUI.inDefaultState, "With a new toolbar it is no longer in a default state."); michael@0: removeCustomToolbars(); // Will call unregisterArea for us michael@0: ok(CustomizableUI.inDefaultState, "When the toolbar is unregistered, " + michael@0: "everything will return to the default state."); michael@0: }); michael@0: michael@0: add_task(function asyncCleanup() { michael@0: yield resetCustomization(); michael@0: });