summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_reset_dom_events.js
blob: 2922fe481d420f152685bb001152281e712cad35 (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
"use strict";

const widgetId = "import-button";
const listener = {
  _beforeCount: 0,
  _afterCount: 0,
  onWidgetBeforeDOMChange(node) {
    if (node.id == widgetId) {
      this._beforeCount++;
    }
  },
  onWidgetAfterDOMChange(node) {
    if (node.id == widgetId) {
      this._afterCount++;
    }
  },
};

add_task(async function test_reset_dom_events() {
  await startCustomizing();

  CustomizableUI.addWidgetToArea(widgetId, CustomizableUI.AREA_BOOKMARKS);
  CustomizableUI.addListener(listener);

  info("Resetting");
  await gCustomizeMode.reset();

  is(listener._beforeCount, 1, "Should've been notified of the mutation");
  is(listener._afterCount, 1, "Should've been notified of the mutation");

  CustomizableUI.removeListener(listener);

  await endCustomizing();
});