summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_switch_to_customize_mode.js
blob: 55e80d351779bc4ed0c4848f79b59eadf71a0a61 (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
42
43
44
45
46
47
48
49
50
51
52
53
"use strict";

add_task(async function () {
  await startCustomizing();
  is(gBrowser.tabs.length, 2, "Should have 2 tabs");

  let paletteKidCount = document.getElementById(
    "customization-palette"
  ).childElementCount;
  let nonCustomizingTab = gBrowser.tabContainer.querySelector(
    "tab:not([customizemode=true])"
  );
  let finishedCustomizing = BrowserTestUtils.waitForEvent(
    gNavToolbox,
    "aftercustomization"
  );
  await BrowserTestUtils.switchTab(gBrowser, nonCustomizingTab);
  await finishedCustomizing;

  let startedCount = 0;
  let handler = e => startedCount++;
  gNavToolbox.addEventListener("customizationstarting", handler);
  await startCustomizing();
  CustomizableUI.removeWidgetFromArea("stop-reload-button");
  await gCustomizeMode.reset().catch(e => {
    ok(
      false,
      "Threw an exception trying to reset after making modifications in customize mode: " +
        e
    );
  });

  let newKidCount = document.getElementById(
    "customization-palette"
  ).childElementCount;
  is(
    newKidCount,
    paletteKidCount,
    "Should have just as many items in the palette as before."
  );
  await endCustomizing();
  is(startedCount, 1, "Should have only started once");
  gNavToolbox.removeEventListener("customizationstarting", handler);
  let customizableToolbars = document.querySelectorAll(
    "toolbar[customizable=true]:not([autohide=true])"
  );
  for (let toolbar of customizableToolbars) {
    ok(
      !toolbar.hasAttribute("customizing"),
      "Toolbar " + toolbar.id + " is no longer customizing"
    );
  }
});