browser/components/customizableui/test/browser_877178_unregisterArea.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/customizableui/test/browser_877178_unregisterArea.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +registerCleanupFunction(removeCustomToolbars);
    1.11 +
    1.12 +// Sanity checks
    1.13 +add_task(function sanityChecks() {
    1.14 +  SimpleTest.doesThrow(function() CustomizableUI.registerArea("@foo"),
    1.15 +                       "Registering areas with an invalid ID should throw.");
    1.16 +
    1.17 +  SimpleTest.doesThrow(function() CustomizableUI.registerArea([]),
    1.18 +                       "Registering areas with an invalid ID should throw.");
    1.19 +
    1.20 +  SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("@foo"),
    1.21 +                       "Unregistering areas with an invalid ID should throw.");
    1.22 +
    1.23 +  SimpleTest.doesThrow(function() CustomizableUI.unregisterArea([]),
    1.24 +                       "Unregistering areas with an invalid ID should throw.");
    1.25 +
    1.26 +  SimpleTest.doesThrow(function() CustomizableUI.unregisterArea("unknown"),
    1.27 +                       "Unregistering an area that's not registered should throw.");
    1.28 +});
    1.29 +
    1.30 +// Check areas are loaded with their default placements.
    1.31 +add_task(function checkLoadedAres() {
    1.32 +  ok(CustomizableUI.inDefaultState, "Everything should be in its default state.");
    1.33 +});
    1.34 +
    1.35 +// Check registering and unregistering a new area.
    1.36 +add_task(function checkRegisteringAndUnregistering() {
    1.37 +  const kToolbarId = "test-registration-toolbar";
    1.38 +  const kButtonId = "test-registration-button";
    1.39 +  createDummyXULButton(kButtonId);
    1.40 +  createToolbarWithPlacements(kToolbarId, ["spring", kButtonId, "spring"]);
    1.41 +  assertAreaPlacements(kToolbarId,
    1.42 +                       [/customizableui-special-spring\d+/,
    1.43 +                        kButtonId,
    1.44 +                        /customizableui-special-spring\d+/]);
    1.45 +  ok(!CustomizableUI.inDefaultState, "With a new toolbar it is no longer in a default state.");
    1.46 +  removeCustomToolbars(); // Will call unregisterArea for us
    1.47 +  ok(CustomizableUI.inDefaultState, "When the toolbar is unregistered, " +
    1.48 +     "everything will return to the default state.");
    1.49 +});
    1.50 +
    1.51 +add_task(function asyncCleanup() {
    1.52 +  yield resetCustomization();
    1.53 +});

mercurial