browser_insert_before_moved_node.js (1545B)
1 "use strict"; 2 3 /** 4 * Check inserting before a node that has moved from the toolbar into a 5 * non-customizable bit of the browser works. 6 */ 7 add_task(async function () { 8 for (let toolbar of ["nav-bar", "TabsToolbar"]) { 9 CustomizableUI.createWidget({ 10 id: "real-button", 11 label: "test real button", 12 }); 13 CustomizableUI.addWidgetToArea("real-button", toolbar); 14 CustomizableUI.addWidgetToArea("moved-button-not-here", toolbar); 15 let placements = CustomizableUI.getWidgetIdsInArea(toolbar); 16 Assert.deepEqual( 17 placements.slice(-2), 18 ["real-button", "moved-button-not-here"], 19 "Should have correct placements" 20 ); 21 let otherButton = document.createXULElement("toolbarbutton"); 22 otherButton.id = "moved-button-not-here"; 23 if (toolbar == "nav-bar") { 24 gURLBar.parentNode.appendChild(otherButton); 25 } else { 26 gBrowser.tabContainer.appendChild(otherButton); 27 } 28 CustomizableUI.destroyWidget("real-button"); 29 CustomizableUI.createWidget({ 30 id: "real-button", 31 label: "test real button", 32 }); 33 34 let button = document.getElementById("real-button"); 35 ok(button, "Button should exist"); 36 if (button) { 37 let expectedContainer = CustomizableUI.getCustomizationTarget( 38 document.getElementById(toolbar) 39 ); 40 is( 41 button.parentNode, 42 expectedContainer, 43 "Button should be in the toolbar" 44 ); 45 } 46 47 CustomizableUI.destroyWidget("real-button"); 48 otherButton.remove(); 49 CustomizableUI.reset(); 50 } 51 });