browser/components/customizableui/test/browser_877178_unregisterArea.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.

     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 registerCleanupFunction(removeCustomToolbars);
     9 // Sanity checks
    10 add_task(function sanityChecks() {
    11   SimpleTest.doesThrow(function() CustomizableUI.registerArea("@foo"),
    12                        "Registering areas with an invalid ID should throw.");
    14   SimpleTest.doesThrow(function() CustomizableUI.registerArea([]),
    15                        "Registering areas with an invalid ID should throw.");
    17   SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("@foo"),
    18                        "Unregistering areas with an invalid ID should throw.");
    20   SimpleTest.doesThrow(function() CustomizableUI.unregisterArea([]),
    21                        "Unregistering areas with an invalid ID should throw.");
    23   SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("unknown"),
    24                        "Unregistering an area that's not registered should throw.");
    25 });
    27 // Check areas are loaded with their default placements.
    28 add_task(function checkLoadedAres() {
    29   ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
    30 });
    32 // Check registering and unregistering a new area.
    33 add_task(function checkRegisteringAndUnregistering() {
    34   const kToolbarId = "test-registration-toolbar";
    35   const kButtonId = "test-registration-button";
    36   createDummyXULButton(kButtonId);
    37   createToolbarWithPlacements(kToolbarId, ["spring", kButtonId, "spring"]);
    38   assertAreaPlacements(kToolbarId,
    39                        [/customizableui-special-spring\d+/,
    40                         kButtonId,
    41                         /customizableui-special-spring\d+/]);
    42   ok(!CustomizableUI.inDefaultState, "With a new toolbar it is no longer in a default state.");
    43   removeCustomToolbars(); // Will call unregisterArea for us
    44   ok(CustomizableUI.inDefaultState, "When the toolbar is unregistered, " +
    45      "everything will return to the default state.");
    46 });
    48 add_task(function asyncCleanup() {
    49   yield resetCustomization();
    50 });

mercurial