tor-browser

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

browser_1096763_seen_widgets_post_reset.js (1229B)


      1 "use strict";
      2 
      3 const BUTTONID = "test-seenwidget-post-reset";
      4 
      5 add_task(async function () {
      6  CustomizableUI.createWidget({
      7    id: BUTTONID,
      8    label: "Test widget seen post reset",
      9    defaultArea: CustomizableUI.AREA_NAVBAR,
     10  });
     11 
     12  const kPrefCustomizationState = "browser.uiCustomization.state";
     13  ok(
     14    CustomizableUI.getTestOnlyInternalProp("gSeenWidgets").has(BUTTONID),
     15    "Widget should be seen after createWidget is called."
     16  );
     17  CustomizableUI.reset();
     18  ok(
     19    CustomizableUI.getTestOnlyInternalProp("gSeenWidgets").has(BUTTONID),
     20    "Widget should still be seen after reset."
     21  );
     22  CustomizableUI.addWidgetToArea(BUTTONID, CustomizableUI.AREA_NAVBAR);
     23  gCustomizeMode.removeFromArea(document.getElementById(BUTTONID));
     24  let hasUserValue = Services.prefs.prefHasUserValue(kPrefCustomizationState);
     25  ok(hasUserValue, "Pref should be set right now.");
     26  if (hasUserValue) {
     27    let seenArray = JSON.parse(
     28      Services.prefs.getCharPref(kPrefCustomizationState)
     29    ).seen;
     30    isnot(
     31      seenArray.indexOf(BUTTONID),
     32      -1,
     33      "Widget should be in saved 'seen' list."
     34    );
     35  }
     36 });
     37 
     38 registerCleanupFunction(function () {
     39  CustomizableUI.destroyWidget(BUTTONID);
     40  CustomizableUI.reset();
     41 });