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