tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_941083_invalidate_wrapper_cache_createWidget.js (1488B)


      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 // See https://bugzilla.mozilla.org/show_bug.cgi?id=941083
      8 
      9 const kWidgetId = "test-invalidate-wrapper-cache";
     10 
     11 // Check createWidget invalidates the widget cache
     12 add_task(function () {
     13  let groupWrapper = CustomizableUI.getWidget(kWidgetId);
     14  ok(groupWrapper, "Should get group wrapper.");
     15  let singleWrapper = groupWrapper.forWindow(window);
     16  ok(singleWrapper, "Should get single wrapper.");
     17 
     18  CustomizableUI.createWidget({
     19    id: kWidgetId,
     20    label: "Test invalidating widgets caching",
     21  });
     22 
     23  let newGroupWrapper = CustomizableUI.getWidget(kWidgetId);
     24  ok(newGroupWrapper, "Should get a group wrapper again.");
     25  isnot(newGroupWrapper, groupWrapper, "Wrappers shouldn't be the same.");
     26  isnot(
     27    newGroupWrapper.provider,
     28    groupWrapper.provider,
     29    "Wrapper providers shouldn't be the same."
     30  );
     31 
     32  let newSingleWrapper = newGroupWrapper.forWindow(window);
     33  isnot(
     34    newSingleWrapper,
     35    singleWrapper,
     36    "Single wrappers shouldn't be the same."
     37  );
     38  isnot(
     39    newSingleWrapper.provider,
     40    singleWrapper.provider,
     41    "Single wrapper providers shouldn't be the same."
     42  );
     43 
     44  CustomizableUI.destroyWidget(kWidgetId);
     45  ok(
     46    !CustomizableUI.getWidget(kWidgetId),
     47    "Shouldn't get a wrapper after destroying the widget."
     48  );
     49 });