browser/components/customizableui/test/browser_987177_xul_wrapper_updating.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 BUTTONID = "test-XUL-wrapper-widget";
     8 add_task(function() {
     9   let btn = createDummyXULButton(BUTTONID, "XUL btn");
    10   gNavToolbox.palette.appendChild(btn);
    11   let groupWrapper = CustomizableUI.getWidget(BUTTONID);
    12   ok(groupWrapper, "Should get a group wrapper");
    13   let singleWrapper = groupWrapper.forWindow(window);
    14   ok(singleWrapper, "Should get a single wrapper");
    15   is(singleWrapper.node, btn, "Node should be in the wrapper");
    16   is(groupWrapper.instances.length, 1, "There should be 1 instance on the group wrapper");
    17   is(groupWrapper.instances[0].node, btn, "Button should be that instance.");
    19   CustomizableUI.addWidgetToArea(BUTTONID, CustomizableUI.AREA_NAVBAR);
    21   let otherSingleWrapper = groupWrapper.forWindow(window);
    22   is(singleWrapper, otherSingleWrapper, "Should get the same wrapper after adding the node to the navbar.");
    23   is(singleWrapper.node, btn, "Node should be in the wrapper");
    24   is(groupWrapper.instances.length, 1, "There should be 1 instance on the group wrapper");
    25   is(groupWrapper.instances[0].node, btn, "Button should be that instance.");
    27   CustomizableUI.removeWidgetFromArea(BUTTONID);
    29   otherSingleWrapper = groupWrapper.forWindow(window);
    30   isnot(singleWrapper, otherSingleWrapper, "Shouldn't get the same wrapper after removing it from the navbar.");
    31   singleWrapper = otherSingleWrapper;
    32   is(singleWrapper.node, btn, "Node should be in the wrapper");
    33   is(groupWrapper.instances.length, 1, "There should be 1 instance on the group wrapper");
    34   is(groupWrapper.instances[0].node, btn, "Button should be that instance.");
    36   btn.remove();
    37   otherSingleWrapper = groupWrapper.forWindow(window);
    38   is(singleWrapper, otherSingleWrapper, "Should get the same wrapper after physically removing the node.");
    39   is(singleWrapper.node, null, "Wrapper's node should be null now that it's left the DOM.");
    40   is(groupWrapper.instances.length, 1, "There should be 1 instance on the group wrapper");
    41   is(groupWrapper.instances[0].node, null, "That instance should be null.");
    43   btn = createDummyXULButton(BUTTONID, "XUL btn");
    44   gNavToolbox.palette.appendChild(btn);
    45   otherSingleWrapper = groupWrapper.forWindow(window);
    46   is(singleWrapper, otherSingleWrapper, "Should get the same wrapper after readding the node.");
    47   is(singleWrapper.node, btn, "Node should be in the wrapper");
    48   is(groupWrapper.instances.length, 1, "There should be 1 instance on the group wrapper");
    49   is(groupWrapper.instances[0].node, btn, "Button should be that instance.");
    51   CustomizableUI.addWidgetToArea(BUTTONID, CustomizableUI.AREA_NAVBAR);
    53   otherSingleWrapper = groupWrapper.forWindow(window);
    54   is(singleWrapper, otherSingleWrapper, "Should get the same wrapper after adding the node to the navbar.");
    55   is(singleWrapper.node, btn, "Node should be in the wrapper");
    56   is(groupWrapper.instances.length, 1, "There should be 1 instance on the group wrapper");
    57   is(groupWrapper.instances[0].node, btn, "Button should be that instance.");
    59   CustomizableUI.removeWidgetFromArea(BUTTONID);
    61   otherSingleWrapper = groupWrapper.forWindow(window);
    62   isnot(singleWrapper, otherSingleWrapper, "Shouldn't get the same wrapper after removing it from the navbar.");
    63   singleWrapper = otherSingleWrapper;
    64   is(singleWrapper.node, btn, "Node should be in the wrapper");
    65   is(groupWrapper.instances.length, 1, "There should be 1 instance on the group wrapper");
    66   is(groupWrapper.instances[0].node, btn, "Button should be that instance.");
    68   btn.remove();
    69   otherSingleWrapper = groupWrapper.forWindow(window);
    70   is(singleWrapper, otherSingleWrapper, "Should get the same wrapper after physically removing the node.");
    71   is(singleWrapper.node, null, "Wrapper's node should be null now that it's left the DOM.");
    72   is(groupWrapper.instances.length, 1, "There should be 1 instance on the group wrapper");
    73   is(groupWrapper.instances[0].node, null, "That instance should be null.");
    74 });

mercurial