browser/components/customizableui/test/browser_886323_buildArea_removable_nodes.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 const kButtonId = "test-886323-removable-moved-node";
     8 const kLazyAreaId = "test-886323-lazy-area-for-removability-testing";
    10 let gNavBar = document.getElementById(CustomizableUI.AREA_NAVBAR);
    11 let gLazyArea;
    13 // Removable nodes shouldn't be moved by buildArea
    14 add_task(function() {
    15   let dummyBtn = createDummyXULButton(kButtonId, "Dummy");
    16   dummyBtn.setAttribute("removable", "true");
    17   gNavBar.customizationTarget.appendChild(dummyBtn);
    18   let popupSet = document.getElementById("mainPopupSet");
    19   gLazyArea = document.createElementNS(kNSXUL, "panel");
    20   gLazyArea.id = kLazyAreaId;
    21   gLazyArea.setAttribute("hidden", "true");
    22   popupSet.appendChild(gLazyArea);
    23   CustomizableUI.registerArea(kLazyAreaId, {
    24     type: CustomizableUI.TYPE_MENU_PANEL,
    25     defaultPlacements: []
    26   });
    27   CustomizableUI.addWidgetToArea(kButtonId, kLazyAreaId);
    28   assertAreaPlacements(kLazyAreaId, [kButtonId],
    29                        "Placements should have changed because widget is removable.");
    30   let btn = document.getElementById(kButtonId);
    31   btn.setAttribute("removable", "false");
    32   gLazyArea.customizationTarget = gLazyArea;
    33   CustomizableUI.registerToolbarNode(gLazyArea, []);
    34   assertAreaPlacements(kLazyAreaId, [], "Placements should no longer include widget.");
    35   is(btn.parentNode.id, gNavBar.customizationTarget.id,
    36      "Button shouldn't actually have moved as it's not removable");
    37   let btn = document.getElementById(kButtonId);
    38   if (btn) btn.remove();
    39   CustomizableUI.removeWidgetFromArea(kButtonId);
    40   CustomizableUI.unregisterArea(kLazyAreaId);
    41   gLazyArea.remove();
    42 });
    44 add_task(function asyncCleanup() {
    45   yield resetCustomization();
    46 });

mercurial