Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
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/. */
5 "use strict";
7 const kToolbarName = "test-specials-toolbar";
9 registerCleanupFunction(removeCustomToolbars);
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.");
17 // Check it's there with a generated ID:
18 assertAreaPlacements(kToolbarName, [/customizableui-special-spring\d+/]);
19 let [springId] = getAreaWidgetIds(kToolbarName);
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);
27 isnot(springId, spring2Id, "Springs shouldn't have identical IDs.");
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 });
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.");
40 // Check it's there with a generated ID:
41 assertAreaPlacements(kToolbarName, [/customizableui-special-separator\d+/]);
42 let [separatorId] = getAreaWidgetIds(kToolbarName);
44 CustomizableUI.addWidgetToArea("separator", kToolbarName);
45 assertAreaPlacements(kToolbarName, [separatorId,
46 /customizableui-special-separator\d+/]);
47 let [, separator2Id] = getAreaWidgetIds(kToolbarName);
49 isnot(separatorId, separator2Id, "Separator ids shouldn't be equal.");
51 CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
52 assertAreaPlacements(kToolbarName, [separatorId, "downloads-button", separator2Id]);
53 yield removeCustomToolbars();
54 });
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.");
61 // Check it's there with a generated ID:
62 assertAreaPlacements(kToolbarName, [/customizableui-special-spacer\d+/]);
63 let [spacerId] = getAreaWidgetIds(kToolbarName);
65 CustomizableUI.addWidgetToArea("spacer", kToolbarName);
66 assertAreaPlacements(kToolbarName, [spacerId,
67 /customizableui-special-spacer\d+/]);
68 let [, spacer2Id] = getAreaWidgetIds(kToolbarName);
70 isnot(spacerId, spacer2Id, "Spacer ids shouldn't be equal.");
72 CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
73 assertAreaPlacements(kToolbarName, [spacerId, "downloads-button", spacer2Id]);
74 yield removeCustomToolbars();
75 });
77 add_task(function asyncCleanup() {
78 yield resetCustomization();
79 });