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