browser_969427_recreate_destroyed_widget_after_reset.js (1227B)
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 function getPlacementArea(id) { 8 let placement = CustomizableUI.getPlacementOfWidget(id); 9 return placement && placement.area; 10 } 11 12 // Check that a destroyed widget recreated after a reset call goes to 13 // the navigation bar. 14 add_task(function () { 15 const kWidgetId = "test-recreate-after-reset"; 16 let spec = { 17 id: kWidgetId, 18 label: "Test re-create after reset.", 19 removable: true, 20 defaultArea: CustomizableUI.AREA_NAVBAR, 21 }; 22 23 CustomizableUI.createWidget(spec); 24 is( 25 getPlacementArea(kWidgetId), 26 CustomizableUI.AREA_NAVBAR, 27 "widget is in the navigation bar" 28 ); 29 30 CustomizableUI.destroyWidget(kWidgetId); 31 isnot( 32 getPlacementArea(kWidgetId), 33 CustomizableUI.AREA_NAVBAR, 34 "widget removed from the navigation bar" 35 ); 36 37 CustomizableUI.reset(); 38 39 CustomizableUI.createWidget(spec); 40 is( 41 getPlacementArea(kWidgetId), 42 CustomizableUI.AREA_NAVBAR, 43 "widget recreated and added back to the nav bar" 44 ); 45 46 CustomizableUI.destroyWidget(kWidgetId); 47 });