browser/components/customizableui/test/browser_941083_invalidate_wrapper_cache_createWidget.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/customizableui/test/browser_941083_invalidate_wrapper_cache_createWidget.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     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 +// See https://bugzilla.mozilla.org/show_bug.cgi?id=941083
    1.11 +
    1.12 +const kWidgetId = "test-invalidate-wrapper-cache";
    1.13 +
    1.14 +// Check createWidget invalidates the widget cache
    1.15 +add_task(function() {
    1.16 +  let groupWrapper = CustomizableUI.getWidget(kWidgetId);
    1.17 +  ok(groupWrapper, "Should get group wrapper.");
    1.18 +  let singleWrapper = groupWrapper.forWindow(window);
    1.19 +  ok(singleWrapper, "Should get single wrapper.");
    1.20 +
    1.21 +  CustomizableUI.createWidget({id: kWidgetId, label: "Test invalidating widgets caching"});
    1.22 +
    1.23 +  let newGroupWrapper = CustomizableUI.getWidget(kWidgetId);
    1.24 +  ok(newGroupWrapper, "Should get a group wrapper again.");
    1.25 +  isnot(newGroupWrapper, groupWrapper, "Wrappers shouldn't be the same.");
    1.26 +  isnot(newGroupWrapper.provider, groupWrapper.provider, "Wrapper providers shouldn't be the same.");
    1.27 +
    1.28 +  let newSingleWrapper = newGroupWrapper.forWindow(window);
    1.29 +  isnot(newSingleWrapper, singleWrapper, "Single wrappers shouldn't be the same.");
    1.30 +  isnot(newSingleWrapper.provider, singleWrapper.provider, "Single wrapper providers shouldn't be the same.");
    1.31 +
    1.32 +  CustomizableUI.destroyWidget(kWidgetId);
    1.33 +  ok(!CustomizableUI.getWidget(kWidgetId), "Shouldn't get a wrapper after destroying the widget.");
    1.34 +});

mercurial