browser_993322_widget_notoolbar.js (1647B)
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(async function () { 11 let toolbar = createToolbarWithPlacements(TOOLBARID, []); 12 CustomizableUI.addWidgetToArea(BUTTONID, TOOLBARID); 13 is( 14 CustomizableUI.getPlacementOfWidget(BUTTONID).area, 15 TOOLBARID, 16 "Should be on toolbar" 17 ); 18 is(toolbar.children.length, 0, "Toolbar has no kid"); 19 20 CustomizableUI.unregisterArea(TOOLBARID); 21 CustomizableUI.createWidget({ 22 id: BUTTONID, 23 label: "Test widget toolbar gone", 24 }); 25 26 let currentWidget = CustomizableUI.getWidget(BUTTONID); 27 28 await startCustomizing(); 29 let buttonNode = document.getElementById(BUTTONID); 30 ok(buttonNode, "Should find button in window"); 31 if (buttonNode) { 32 is( 33 buttonNode.parentNode.localName, 34 "toolbarpaletteitem", 35 "Node should be wrapped" 36 ); 37 is( 38 buttonNode.parentNode.getAttribute("place"), 39 "palette", 40 "Node should be in palette" 41 ); 42 is( 43 buttonNode, 44 gNavToolbox.palette.querySelector("#" + BUTTONID), 45 "Node should really be in palette." 46 ); 47 } 48 is( 49 currentWidget.forWindow(window).node, 50 buttonNode, 51 "Should have the same node for customize mode" 52 ); 53 await endCustomizing(); 54 55 CustomizableUI.destroyWidget(BUTTONID); 56 CustomizableUI.unregisterArea(TOOLBARID, true); 57 toolbar.remove(); 58 gAddedToolbars.clear(); 59 });