|
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/. */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 const BUTTONID = "test-XUL-wrapper-destroyWidget"; |
|
8 |
|
9 |
|
10 add_task(function() { |
|
11 let btn = createDummyXULButton(BUTTONID, "XUL btn"); |
|
12 gNavToolbox.palette.appendChild(btn); |
|
13 let firstWrapper = CustomizableUI.getWidget(BUTTONID).forWindow(window); |
|
14 ok(firstWrapper, "Should get a wrapper"); |
|
15 ok(firstWrapper.node, "Node should be there on first wrapper."); |
|
16 |
|
17 btn.remove(); |
|
18 CustomizableUI.destroyWidget(BUTTONID); |
|
19 let secondWrapper = CustomizableUI.getWidget(BUTTONID).forWindow(window); |
|
20 isnot(firstWrapper, secondWrapper, "Wrappers should be different after destroyWidget call."); |
|
21 ok(!firstWrapper.node, "No node should be there on old wrapper."); |
|
22 ok(!secondWrapper.node, "No node should be there on new wrapper."); |
|
23 |
|
24 btn = createDummyXULButton(BUTTONID, "XUL btn"); |
|
25 gNavToolbox.palette.appendChild(btn); |
|
26 let thirdWrapper = CustomizableUI.getWidget(BUTTONID).forWindow(window); |
|
27 ok(thirdWrapper, "Should get a wrapper"); |
|
28 is(secondWrapper, thirdWrapper, "Should get the second wrapper again."); |
|
29 ok(firstWrapper.node, "Node should be there on old wrapper."); |
|
30 ok(secondWrapper.node, "Node should be there on second wrapper."); |
|
31 ok(thirdWrapper.node, "Node should be there on third wrapper."); |
|
32 }); |
|
33 |