summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_1096763_seen_widgets_post_reset.js
blob: 74854f499c9302d841e4ea1b10b25e1d1f5e5e04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"use strict";

const BUTTONID = "test-seenwidget-post-reset";

add_task(async function () {
  CustomizableUI.createWidget({
    id: BUTTONID,
    label: "Test widget seen post reset",
    defaultArea: CustomizableUI.AREA_NAVBAR,
  });

  const kPrefCustomizationState = "browser.uiCustomization.state";
  ok(
    CustomizableUI.getTestOnlyInternalProp("gSeenWidgets").has(BUTTONID),
    "Widget should be seen after createWidget is called."
  );
  CustomizableUI.reset();
  ok(
    CustomizableUI.getTestOnlyInternalProp("gSeenWidgets").has(BUTTONID),
    "Widget should still be seen after reset."
  );
  CustomizableUI.addWidgetToArea(BUTTONID, CustomizableUI.AREA_NAVBAR);
  gCustomizeMode.removeFromArea(document.getElementById(BUTTONID));
  let hasUserValue = Services.prefs.prefHasUserValue(kPrefCustomizationState);
  ok(hasUserValue, "Pref should be set right now.");
  if (hasUserValue) {
    let seenArray = JSON.parse(
      Services.prefs.getCharPref(kPrefCustomizationState)
    ).seen;
    isnot(
      seenArray.indexOf(BUTTONID),
      -1,
      "Widget should be in saved 'seen' list."
    );
  }
});

registerCleanupFunction(function () {
  CustomizableUI.destroyWidget(BUTTONID);
  CustomizableUI.reset();
});