|
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 // Calling CustomizableUI.registerArea twice with no |
|
8 // properties should not throw an exception. |
|
9 add_task(function() { |
|
10 try { |
|
11 CustomizableUI.registerArea("area-996364", {}); |
|
12 CustomizableUI.registerArea("area-996364", {}); |
|
13 } catch (ex) { |
|
14 ok(false, ex.message); |
|
15 } |
|
16 |
|
17 CustomizableUI.unregisterArea("area-996364", true); |
|
18 }); |
|
19 |
|
20 add_task(function() { |
|
21 let exceptionThrown = false; |
|
22 try { |
|
23 CustomizableUI.registerArea("area-996364-2", {type: CustomizableUI.TYPE_TOOLBAR, defaultCollapsed: "false"}); |
|
24 } catch (ex) { |
|
25 exceptionThrown = true; |
|
26 } |
|
27 ok(exceptionThrown, "defaultCollapsed is not allowed as an external property"); |
|
28 |
|
29 // No need to unregister the area because registration fails. |
|
30 }); |
|
31 |
|
32 add_task(function() { |
|
33 let exceptionThrown; |
|
34 try { |
|
35 CustomizableUI.registerArea("area-996364-3", {type: CustomizableUI.TYPE_TOOLBAR}); |
|
36 CustomizableUI.registerArea("area-996364-3", {type: CustomizableUI.TYPE_MENU_PANEL}); |
|
37 } catch (ex) { |
|
38 exceptionThrown = ex; |
|
39 } |
|
40 ok(exceptionThrown, "Exception expected, an area cannot change types: " + (exceptionThrown ? exceptionThrown : "[no exception]")); |
|
41 |
|
42 CustomizableUI.unregisterArea("area-996364-3", true); |
|
43 }); |
|
44 |
|
45 add_task(function() { |
|
46 let exceptionThrown; |
|
47 try { |
|
48 CustomizableUI.registerArea("area-996364-4", {type: CustomizableUI.TYPE_MENU_PANEL}); |
|
49 CustomizableUI.registerArea("area-996364-4", {type: CustomizableUI.TYPE_TOOLBAR}); |
|
50 } catch (ex) { |
|
51 exceptionThrown = ex; |
|
52 } |
|
53 ok(exceptionThrown, "Exception expected, an area cannot change types: " + (exceptionThrown ? exceptionThrown : "[no exception]")); |
|
54 |
|
55 CustomizableUI.unregisterArea("area-996364-4", true); |
|
56 }); |
|
57 |
|
58 add_task(function() { |
|
59 let exceptionThrown; |
|
60 try { |
|
61 CustomizableUI.registerArea("area-996899-1", { anchor: "PanelUI-menu-button", |
|
62 type: CustomizableUI.TYPE_MENU_PANEL, |
|
63 defaultPlacements: [] }); |
|
64 CustomizableUI.registerArea("area-996899-1", { anchor: "home-button", |
|
65 type: CustomizableUI.TYPE_MENU_PANEL, |
|
66 defaultPlacements: [] }); |
|
67 } catch (ex) { |
|
68 exceptionThrown = ex; |
|
69 } |
|
70 ok(!exceptionThrown, "Changing anchors shouldn't throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); |
|
71 CustomizableUI.unregisterArea("area-996899-1", true); |
|
72 }); |
|
73 |
|
74 add_task(function() { |
|
75 let exceptionThrown; |
|
76 try { |
|
77 CustomizableUI.registerArea("area-996899-2", { anchor: "PanelUI-menu-button", |
|
78 type: CustomizableUI.TYPE_MENU_PANEL, |
|
79 defaultPlacements: [] }); |
|
80 CustomizableUI.registerArea("area-996899-2", { anchor: "PanelUI-menu-button", |
|
81 type: CustomizableUI.TYPE_MENU_PANEL, |
|
82 defaultPlacements: ["feed-button"] }); |
|
83 } catch (ex) { |
|
84 exceptionThrown = ex; |
|
85 } |
|
86 ok(!exceptionThrown, "Changing defaultPlacements shouldn't throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); |
|
87 CustomizableUI.unregisterArea("area-996899-2", true); |
|
88 }); |
|
89 |
|
90 add_task(function() { |
|
91 let exceptionThrown; |
|
92 try { |
|
93 CustomizableUI.registerArea("area-996899-3", { legacy: true }); |
|
94 CustomizableUI.registerArea("area-996899-3", { legacy: false }); |
|
95 } catch (ex) { |
|
96 exceptionThrown = ex; |
|
97 } |
|
98 ok(exceptionThrown, "Changing 'legacy' should throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); |
|
99 CustomizableUI.unregisterArea("area-996899-3", true); |
|
100 }); |
|
101 |
|
102 add_task(function() { |
|
103 let exceptionThrown; |
|
104 try { |
|
105 CustomizableUI.registerArea("area-996899-4", { overflowable: true }); |
|
106 CustomizableUI.registerArea("area-996899-4", { overflowable: false }); |
|
107 } catch (ex) { |
|
108 exceptionThrown = ex; |
|
109 } |
|
110 ok(exceptionThrown, "Changing 'overflowable' should throw an exception: " + (exceptionThrown ? exceptionThrown : "[no exception]")); |
|
111 CustomizableUI.unregisterArea("area-996899-4", true); |
|
112 }); |