browser/components/customizableui/test/browser_873501_handle_specials.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:30376cd02aa5
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 const kToolbarName = "test-specials-toolbar";
8
9 registerCleanupFunction(removeCustomToolbars);
10
11 // Add a toolbar with two springs and the downloads button.
12 add_task(function addToolbarWith2SpringsAndDownloadsButton() {
13 // Create the toolbar with a single spring:
14 createToolbarWithPlacements(kToolbarName, ["spring"]);
15 ok(document.getElementById(kToolbarName), "Toolbar should be created.");
16
17 // Check it's there with a generated ID:
18 assertAreaPlacements(kToolbarName, [/customizableui-special-spring\d+/]);
19 let [springId] = getAreaWidgetIds(kToolbarName);
20
21 // Add a second spring, check if that's there and doesn't share IDs
22 CustomizableUI.addWidgetToArea("spring", kToolbarName);
23 assertAreaPlacements(kToolbarName, [springId,
24 /customizableui-special-spring\d+/]);
25 let [, spring2Id] = getAreaWidgetIds(kToolbarName);
26
27 isnot(springId, spring2Id, "Springs shouldn't have identical IDs.");
28
29 // Try moving the downloads button to this new toolbar, between the two springs:
30 CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
31 assertAreaPlacements(kToolbarName, [springId, "downloads-button", spring2Id]);
32 yield removeCustomToolbars();
33 });
34
35 // Add separators around the downloads button.
36 add_task(function addSeparatorsAroundDownloadsButton() {
37 createToolbarWithPlacements(kToolbarName, ["separator"]);
38 ok(document.getElementById(kToolbarName), "Toolbar should be created.");
39
40 // Check it's there with a generated ID:
41 assertAreaPlacements(kToolbarName, [/customizableui-special-separator\d+/]);
42 let [separatorId] = getAreaWidgetIds(kToolbarName);
43
44 CustomizableUI.addWidgetToArea("separator", kToolbarName);
45 assertAreaPlacements(kToolbarName, [separatorId,
46 /customizableui-special-separator\d+/]);
47 let [, separator2Id] = getAreaWidgetIds(kToolbarName);
48
49 isnot(separatorId, separator2Id, "Separator ids shouldn't be equal.");
50
51 CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
52 assertAreaPlacements(kToolbarName, [separatorId, "downloads-button", separator2Id]);
53 yield removeCustomToolbars();
54 });
55
56 // Add spacers around the downloads button.
57 add_task(function addSpacersAroundDownloadsButton() {
58 createToolbarWithPlacements(kToolbarName, ["spacer"]);
59 ok(document.getElementById(kToolbarName), "Toolbar should be created.");
60
61 // Check it's there with a generated ID:
62 assertAreaPlacements(kToolbarName, [/customizableui-special-spacer\d+/]);
63 let [spacerId] = getAreaWidgetIds(kToolbarName);
64
65 CustomizableUI.addWidgetToArea("spacer", kToolbarName);
66 assertAreaPlacements(kToolbarName, [spacerId,
67 /customizableui-special-spacer\d+/]);
68 let [, spacer2Id] = getAreaWidgetIds(kToolbarName);
69
70 isnot(spacerId, spacer2Id, "Spacer ids shouldn't be equal.");
71
72 CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
73 assertAreaPlacements(kToolbarName, [spacerId, "downloads-button", spacer2Id]);
74 yield removeCustomToolbars();
75 });
76
77 add_task(function asyncCleanup() {
78 yield resetCustomization();
79 });

mercurial