browser_877178_unregisterArea.js (2046B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 registerCleanupFunction(removeCustomToolbars); 8 9 // Sanity checks 10 add_task(function sanityChecks() { 11 SimpleTest.doesThrow( 12 () => CustomizableUI.registerArea("@foo"), 13 "Registering areas with an invalid ID should throw." 14 ); 15 16 SimpleTest.doesThrow( 17 () => CustomizableUI.registerArea([]), 18 "Registering areas with an invalid ID should throw." 19 ); 20 21 SimpleTest.doesThrow( 22 () => CustomizableUI.unregisterArea("@foo"), 23 "Unregistering areas with an invalid ID should throw." 24 ); 25 26 SimpleTest.doesThrow( 27 () => CustomizableUI.unregisterArea([]), 28 "Unregistering areas with an invalid ID should throw." 29 ); 30 31 SimpleTest.doesThrow( 32 () => CustomizableUI.unregisterArea("unknown"), 33 "Unregistering an area that's not registered should throw." 34 ); 35 }); 36 37 // Check areas are loaded with their default placements. 38 add_task(function checkLoadedAres() { 39 ok( 40 CustomizableUI.inDefaultState, 41 "Everything should be in its default state." 42 ); 43 }); 44 45 // Check registering and unregistering a new area. 46 add_task(function checkRegisteringAndUnregistering() { 47 const kToolbarId = "test-registration-toolbar"; 48 const kButtonId = "test-registration-button"; 49 createDummyXULButton(kButtonId); 50 createToolbarWithPlacements(kToolbarId, ["spring", kButtonId, "spring"]); 51 assertAreaPlacements(kToolbarId, [ 52 /customizableui-special-spring\d+/, 53 kButtonId, 54 /customizableui-special-spring\d+/, 55 ]); 56 ok( 57 !CustomizableUI.inDefaultState, 58 "With a new toolbar it is no longer in a default state." 59 ); 60 removeCustomToolbars(); // Will call unregisterArea for us 61 ok( 62 CustomizableUI.inDefaultState, 63 "When the toolbar is unregistered, " + 64 "everything will return to the default state." 65 ); 66 }); 67 68 add_task(async function asyncCleanup() { 69 await resetCustomization(); 70 });