michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: const kToolbarName = "test-specials-toolbar"; michael@0: michael@0: registerCleanupFunction(removeCustomToolbars); michael@0: michael@0: // Add a toolbar with two springs and the downloads button. michael@0: add_task(function addToolbarWith2SpringsAndDownloadsButton() { michael@0: // Create the toolbar with a single spring: michael@0: createToolbarWithPlacements(kToolbarName, ["spring"]); michael@0: ok(document.getElementById(kToolbarName), "Toolbar should be created."); michael@0: michael@0: // Check it's there with a generated ID: michael@0: assertAreaPlacements(kToolbarName, [/customizableui-special-spring\d+/]); michael@0: let [springId] = getAreaWidgetIds(kToolbarName); michael@0: michael@0: // Add a second spring, check if that's there and doesn't share IDs michael@0: CustomizableUI.addWidgetToArea("spring", kToolbarName); michael@0: assertAreaPlacements(kToolbarName, [springId, michael@0: /customizableui-special-spring\d+/]); michael@0: let [, spring2Id] = getAreaWidgetIds(kToolbarName); michael@0: michael@0: isnot(springId, spring2Id, "Springs shouldn't have identical IDs."); michael@0: michael@0: // Try moving the downloads button to this new toolbar, between the two springs: michael@0: CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1); michael@0: assertAreaPlacements(kToolbarName, [springId, "downloads-button", spring2Id]); michael@0: yield removeCustomToolbars(); michael@0: }); michael@0: michael@0: // Add separators around the downloads button. michael@0: add_task(function addSeparatorsAroundDownloadsButton() { michael@0: createToolbarWithPlacements(kToolbarName, ["separator"]); michael@0: ok(document.getElementById(kToolbarName), "Toolbar should be created."); michael@0: michael@0: // Check it's there with a generated ID: michael@0: assertAreaPlacements(kToolbarName, [/customizableui-special-separator\d+/]); michael@0: let [separatorId] = getAreaWidgetIds(kToolbarName); michael@0: michael@0: CustomizableUI.addWidgetToArea("separator", kToolbarName); michael@0: assertAreaPlacements(kToolbarName, [separatorId, michael@0: /customizableui-special-separator\d+/]); michael@0: let [, separator2Id] = getAreaWidgetIds(kToolbarName); michael@0: michael@0: isnot(separatorId, separator2Id, "Separator ids shouldn't be equal."); michael@0: michael@0: CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1); michael@0: assertAreaPlacements(kToolbarName, [separatorId, "downloads-button", separator2Id]); michael@0: yield removeCustomToolbars(); michael@0: }); michael@0: michael@0: // Add spacers around the downloads button. michael@0: add_task(function addSpacersAroundDownloadsButton() { michael@0: createToolbarWithPlacements(kToolbarName, ["spacer"]); michael@0: ok(document.getElementById(kToolbarName), "Toolbar should be created."); michael@0: michael@0: // Check it's there with a generated ID: michael@0: assertAreaPlacements(kToolbarName, [/customizableui-special-spacer\d+/]); michael@0: let [spacerId] = getAreaWidgetIds(kToolbarName); michael@0: michael@0: CustomizableUI.addWidgetToArea("spacer", kToolbarName); michael@0: assertAreaPlacements(kToolbarName, [spacerId, michael@0: /customizableui-special-spacer\d+/]); michael@0: let [, spacer2Id] = getAreaWidgetIds(kToolbarName); michael@0: michael@0: isnot(spacerId, spacer2Id, "Spacer ids shouldn't be equal."); michael@0: michael@0: CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1); michael@0: assertAreaPlacements(kToolbarName, [spacerId, "downloads-button", spacer2Id]); michael@0: yield removeCustomToolbars(); michael@0: }); michael@0: michael@0: add_task(function asyncCleanup() { michael@0: yield resetCustomization(); michael@0: });