browser/components/customizableui/test/browser_873501_handle_specials.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 const kToolbarName = "test-specials-toolbar";
michael@0 8
michael@0 9 registerCleanupFunction(removeCustomToolbars);
michael@0 10
michael@0 11 // Add a toolbar with two springs and the downloads button.
michael@0 12 add_task(function addToolbarWith2SpringsAndDownloadsButton() {
michael@0 13 // Create the toolbar with a single spring:
michael@0 14 createToolbarWithPlacements(kToolbarName, ["spring"]);
michael@0 15 ok(document.getElementById(kToolbarName), "Toolbar should be created.");
michael@0 16
michael@0 17 // Check it's there with a generated ID:
michael@0 18 assertAreaPlacements(kToolbarName, [/customizableui-special-spring\d+/]);
michael@0 19 let [springId] = getAreaWidgetIds(kToolbarName);
michael@0 20
michael@0 21 // Add a second spring, check if that's there and doesn't share IDs
michael@0 22 CustomizableUI.addWidgetToArea("spring", kToolbarName);
michael@0 23 assertAreaPlacements(kToolbarName, [springId,
michael@0 24 /customizableui-special-spring\d+/]);
michael@0 25 let [, spring2Id] = getAreaWidgetIds(kToolbarName);
michael@0 26
michael@0 27 isnot(springId, spring2Id, "Springs shouldn't have identical IDs.");
michael@0 28
michael@0 29 // Try moving the downloads button to this new toolbar, between the two springs:
michael@0 30 CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
michael@0 31 assertAreaPlacements(kToolbarName, [springId, "downloads-button", spring2Id]);
michael@0 32 yield removeCustomToolbars();
michael@0 33 });
michael@0 34
michael@0 35 // Add separators around the downloads button.
michael@0 36 add_task(function addSeparatorsAroundDownloadsButton() {
michael@0 37 createToolbarWithPlacements(kToolbarName, ["separator"]);
michael@0 38 ok(document.getElementById(kToolbarName), "Toolbar should be created.");
michael@0 39
michael@0 40 // Check it's there with a generated ID:
michael@0 41 assertAreaPlacements(kToolbarName, [/customizableui-special-separator\d+/]);
michael@0 42 let [separatorId] = getAreaWidgetIds(kToolbarName);
michael@0 43
michael@0 44 CustomizableUI.addWidgetToArea("separator", kToolbarName);
michael@0 45 assertAreaPlacements(kToolbarName, [separatorId,
michael@0 46 /customizableui-special-separator\d+/]);
michael@0 47 let [, separator2Id] = getAreaWidgetIds(kToolbarName);
michael@0 48
michael@0 49 isnot(separatorId, separator2Id, "Separator ids shouldn't be equal.");
michael@0 50
michael@0 51 CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
michael@0 52 assertAreaPlacements(kToolbarName, [separatorId, "downloads-button", separator2Id]);
michael@0 53 yield removeCustomToolbars();
michael@0 54 });
michael@0 55
michael@0 56 // Add spacers around the downloads button.
michael@0 57 add_task(function addSpacersAroundDownloadsButton() {
michael@0 58 createToolbarWithPlacements(kToolbarName, ["spacer"]);
michael@0 59 ok(document.getElementById(kToolbarName), "Toolbar should be created.");
michael@0 60
michael@0 61 // Check it's there with a generated ID:
michael@0 62 assertAreaPlacements(kToolbarName, [/customizableui-special-spacer\d+/]);
michael@0 63 let [spacerId] = getAreaWidgetIds(kToolbarName);
michael@0 64
michael@0 65 CustomizableUI.addWidgetToArea("spacer", kToolbarName);
michael@0 66 assertAreaPlacements(kToolbarName, [spacerId,
michael@0 67 /customizableui-special-spacer\d+/]);
michael@0 68 let [, spacer2Id] = getAreaWidgetIds(kToolbarName);
michael@0 69
michael@0 70 isnot(spacerId, spacer2Id, "Spacer ids shouldn't be equal.");
michael@0 71
michael@0 72 CustomizableUI.addWidgetToArea("downloads-button", kToolbarName, 1);
michael@0 73 assertAreaPlacements(kToolbarName, [spacerId, "downloads-button", spacer2Id]);
michael@0 74 yield removeCustomToolbars();
michael@0 75 });
michael@0 76
michael@0 77 add_task(function asyncCleanup() {
michael@0 78 yield resetCustomization();
michael@0 79 });

mercurial