|
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-API-created-widget-toolbar-gone"; |
|
8 const TOOLBARID = "test-API-created-extra-toolbar"; |
|
9 |
|
10 add_task(function*() { |
|
11 let toolbar = createToolbarWithPlacements(TOOLBARID, []); |
|
12 CustomizableUI.addWidgetToArea(BUTTONID, TOOLBARID); |
|
13 is(CustomizableUI.getPlacementOfWidget(BUTTONID).area, TOOLBARID, "Should be on toolbar"); |
|
14 is(toolbar.children.length, 0, "Toolbar has no kid"); |
|
15 |
|
16 CustomizableUI.unregisterArea(TOOLBARID); |
|
17 CustomizableUI.createWidget({id: BUTTONID, label: "Test widget toolbar gone"}); |
|
18 |
|
19 let currentWidget = CustomizableUI.getWidget(BUTTONID); |
|
20 |
|
21 yield startCustomizing(); |
|
22 let buttonNode = document.getElementById(BUTTONID); |
|
23 ok(buttonNode, "Should find button in window"); |
|
24 if (buttonNode) { |
|
25 is(buttonNode.parentNode.localName, "toolbarpaletteitem", "Node should be wrapped"); |
|
26 is(buttonNode.parentNode.getAttribute("place"), "palette", "Node should be in palette"); |
|
27 is(buttonNode, gNavToolbox.palette.querySelector("#" + BUTTONID), "Node should really be in palette."); |
|
28 } |
|
29 is(currentWidget.forWindow(window).node, buttonNode, "Should have the same node for customize mode"); |
|
30 yield endCustomizing(); |
|
31 |
|
32 CustomizableUI.destroyWidget(BUTTONID); |
|
33 CustomizableUI.unregisterArea(TOOLBARID, true); |
|
34 toolbar.remove(); |
|
35 gAddedToolbars.clear(); |
|
36 }); |