1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_987177_destroyWidget_xul.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,33 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +const BUTTONID = "test-XUL-wrapper-destroyWidget"; 1.11 + 1.12 + 1.13 +add_task(function() { 1.14 + let btn = createDummyXULButton(BUTTONID, "XUL btn"); 1.15 + gNavToolbox.palette.appendChild(btn); 1.16 + let firstWrapper = CustomizableUI.getWidget(BUTTONID).forWindow(window); 1.17 + ok(firstWrapper, "Should get a wrapper"); 1.18 + ok(firstWrapper.node, "Node should be there on first wrapper."); 1.19 + 1.20 + btn.remove(); 1.21 + CustomizableUI.destroyWidget(BUTTONID); 1.22 + let secondWrapper = CustomizableUI.getWidget(BUTTONID).forWindow(window); 1.23 + isnot(firstWrapper, secondWrapper, "Wrappers should be different after destroyWidget call."); 1.24 + ok(!firstWrapper.node, "No node should be there on old wrapper."); 1.25 + ok(!secondWrapper.node, "No node should be there on new wrapper."); 1.26 + 1.27 + btn = createDummyXULButton(BUTTONID, "XUL btn"); 1.28 + gNavToolbox.palette.appendChild(btn); 1.29 + let thirdWrapper = CustomizableUI.getWidget(BUTTONID).forWindow(window); 1.30 + ok(thirdWrapper, "Should get a wrapper"); 1.31 + is(secondWrapper, thirdWrapper, "Should get the second wrapper again."); 1.32 + ok(firstWrapper.node, "Node should be there on old wrapper."); 1.33 + ok(secondWrapper.node, "Node should be there on second wrapper."); 1.34 + ok(thirdWrapper.node, "Node should be there on third wrapper."); 1.35 +}); 1.36 +