|
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(function() CustomizableUI.registerArea("@foo"), |
|
12 "Registering areas with an invalid ID should throw."); |
|
13 |
|
14 SimpleTest.doesThrow(function() CustomizableUI.registerArea([]), |
|
15 "Registering areas with an invalid ID should throw."); |
|
16 |
|
17 SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("@foo"), |
|
18 "Unregistering areas with an invalid ID should throw."); |
|
19 |
|
20 SimpleTest.doesThrow(function() CustomizableUI.unregisterArea([]), |
|
21 "Unregistering areas with an invalid ID should throw."); |
|
22 |
|
23 SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("unknown"), |
|
24 "Unregistering an area that's not registered should throw."); |
|
25 }); |
|
26 |
|
27 // Check areas are loaded with their default placements. |
|
28 add_task(function checkLoadedAres() { |
|
29 ok(CustomizableUI.inDefaultState, "Everything should be in its default state."); |
|
30 }); |
|
31 |
|
32 // Check registering and unregistering a new area. |
|
33 add_task(function checkRegisteringAndUnregistering() { |
|
34 const kToolbarId = "test-registration-toolbar"; |
|
35 const kButtonId = "test-registration-button"; |
|
36 createDummyXULButton(kButtonId); |
|
37 createToolbarWithPlacements(kToolbarId, ["spring", kButtonId, "spring"]); |
|
38 assertAreaPlacements(kToolbarId, |
|
39 [/customizableui-special-spring\d+/, |
|
40 kButtonId, |
|
41 /customizableui-special-spring\d+/]); |
|
42 ok(!CustomizableUI.inDefaultState, "With a new toolbar it is no longer in a default state."); |
|
43 removeCustomToolbars(); // Will call unregisterArea for us |
|
44 ok(CustomizableUI.inDefaultState, "When the toolbar is unregistered, " + |
|
45 "everything will return to the default state."); |
|
46 }); |
|
47 |
|
48 add_task(function asyncCleanup() { |
|
49 yield resetCustomization(); |
|
50 }); |