summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_996364_registerArea_different_properties.js
blob: 7d8ea591509db1f31fd2dca71bd7cbdd8d0b99f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

// Calling CustomizableUI.registerArea twice with no
// properties should not throw an exception.
add_task(function () {
  try {
    CustomizableUI.registerArea("area-996364", {});
    CustomizableUI.registerArea("area-996364", {});
  } catch (ex) {
    ok(false, ex.message);
  }

  CustomizableUI.unregisterArea("area-996364", true);
});

add_task(function () {
  let exceptionThrown = false;
  try {
    CustomizableUI.registerArea("area-996364-2", {
      type: CustomizableUI.TYPE_TOOLBAR,
      defaultCollapsed: "false",
    });
  } catch (ex) {
    exceptionThrown = true;
  }
  ok(
    exceptionThrown,
    "defaultCollapsed is not allowed as an external property"
  );

  // No need to unregister the area because registration fails.
});

add_task(function () {
  let exceptionThrown;
  try {
    CustomizableUI.registerArea("area-996364-3", {
      type: CustomizableUI.TYPE_TOOLBAR,
    });
    CustomizableUI.registerArea("area-996364-3", {
      type: CustomizableUI.TYPE_PANEL,
    });
  } catch (ex) {
    exceptionThrown = ex;
  }
  ok(
    exceptionThrown,
    "Exception expected, an area cannot change types: " +
      (exceptionThrown ? exceptionThrown : "[no exception]")
  );

  CustomizableUI.unregisterArea("area-996364-3", true);
});

add_task(function () {
  let exceptionThrown;
  try {
    CustomizableUI.registerArea("area-996364-4", {
      type: CustomizableUI.TYPE_PANEL,
    });
    CustomizableUI.registerArea("area-996364-4", {
      type: CustomizableUI.TYPE_TOOLBAR,
    });
  } catch (ex) {
    exceptionThrown = ex;
  }
  ok(
    exceptionThrown,
    "Exception expected, an area cannot change types: " +
      (exceptionThrown ? exceptionThrown : "[no exception]")
  );

  CustomizableUI.unregisterArea("area-996364-4", true);
});

add_task(function () {
  let exceptionThrown;
  try {
    CustomizableUI.registerArea("area-996899-1", {
      anchor: "PanelUI-menu-button",
      type: CustomizableUI.TYPE_PANEL,
      defaultPlacements: [],
    });
    CustomizableUI.registerArea("area-996899-1", {
      anchor: "home-button",
      type: CustomizableUI.TYPE_PANEL,
      defaultPlacements: [],
    });
  } catch (ex) {
    exceptionThrown = ex;
  }
  ok(
    !exceptionThrown,
    "Changing anchors shouldn't throw an exception: " +
      (exceptionThrown ? exceptionThrown : "[no exception]")
  );
  CustomizableUI.unregisterArea("area-996899-1", true);
});

add_task(function () {
  let exceptionThrown;
  try {
    CustomizableUI.registerArea("area-996899-2", {
      anchor: "PanelUI-menu-button",
      type: CustomizableUI.TYPE_PANEL,
      defaultPlacements: [],
    });
    CustomizableUI.registerArea("area-996899-2", {
      anchor: "PanelUI-menu-button",
      type: CustomizableUI.TYPE_PANEL,
      defaultPlacements: ["new-window-button"],
    });
  } catch (ex) {
    exceptionThrown = ex;
  }
  ok(
    !exceptionThrown,
    "Changing defaultPlacements shouldn't throw an exception: " +
      (exceptionThrown ? exceptionThrown : "[no exception]")
  );
  CustomizableUI.unregisterArea("area-996899-2", true);
});

add_task(function () {
  let exceptionThrown;
  try {
    CustomizableUI.registerArea("area-996899-4", { overflowable: true });
    CustomizableUI.registerArea("area-996899-4", { overflowable: false });
  } catch (ex) {
    exceptionThrown = ex;
  }
  ok(
    exceptionThrown,
    "Changing 'overflowable' should throw an exception: " +
      (exceptionThrown ? exceptionThrown : "[no exception]")
  );
  CustomizableUI.unregisterArea("area-996899-4", true);
});