summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_customizemode_contextmenu_menubuttonstate.js
blob: a268faa58a53ee7b7367491b4b635cc0ba8e9602 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"use strict";

add_task(async function() {
  ok(
    !PanelUI.menuButton.hasAttribute("open"),
    "Menu button should not be 'pressed' outside customize mode"
  );
  ok(
    !PanelUI.menuButton.hasAttribute("disabled"),
    "Menu button should not be disabled outside of customize mode"
  );
  await startCustomizing();

  ok(
    !PanelUI.menuButton.hasAttribute("open"),
    "Menu button should still not be 'pressed' when in customize mode"
  );
  is(
    PanelUI.menuButton.getAttribute("disabled"),
    "true",
    "Menu button should be disabled in customize mode"
  );

  let contextMenu = document.getElementById(
    "customizationPaletteItemContextMenu"
  );
  let shownPromise = popupShown(contextMenu);
  let newWindowButton = document.getElementById("wrapper-new-window-button");
  EventUtils.synthesizeMouse(newWindowButton, 2, 2, {
    type: "contextmenu",
    button: 2,
  });
  await shownPromise;
  ok(
    !PanelUI.menuButton.hasAttribute("open"),
    "Menu button should still not be 'pressed' when in customize mode after opening a context menu"
  );
  is(
    PanelUI.menuButton.getAttribute("disabled"),
    "true",
    "Menu button should still be disabled in customize mode"
  );
  is(
    PanelUI.menuButton.getAttribute("disabled"),
    "true",
    "Menu button should still be disabled in customize mode after opening context menu"
  );

  let hiddenContextPromise = popupHidden(contextMenu);
  contextMenu.hidePopup();
  await hiddenContextPromise;
  ok(
    !PanelUI.menuButton.hasAttribute("open"),
    "Menu button should still not be 'pressed' when in customize mode after hiding a context menu"
  );
  is(
    PanelUI.menuButton.getAttribute("disabled"),
    "true",
    "Menu button should still be disabled in customize mode after hiding context menu"
  );
  await endCustomizing();

  ok(
    !PanelUI.menuButton.hasAttribute("open"),
    "Menu button should not be 'pressed' after ending customize mode"
  );
  ok(
    !PanelUI.menuButton.hasAttribute("disabled"),
    "Menu button should not be disabled after ending customize mode"
  );
});