summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/tabs/browser_multiselect_tabs_move.js
blob: e5de60ea996879c32020aef0f86a482ca0b89f07 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
add_task(async function testMoveStartEnabledClickedFromNonSelectedTab() {
  let tab = gBrowser.selectedTab;
  let tab2 = await addTab();
  let tab3 = await addTab();

  let tabs = [tab2, tab3];

  let menuItemMoveStartTab = document.getElementById("context_moveToStart");

  await triggerClickOn(tab, {});
  await triggerClickOn(tab2, { ctrlKey: true });

  ok(tab.multiselected, "Tab is multiselected");
  ok(tab2.multiselected, "Tab2 is multiselected");

  updateTabContextMenu(tab3);
  is(menuItemMoveStartTab.disabled, false, "Move Tab to Start is enabled");

  for (let tabToRemove of tabs) {
    BrowserTestUtils.removeTab(tabToRemove);
  }
});

add_task(async function testMoveStartDisabledFromFirstUnpinnedTab() {
  let tab = gBrowser.selectedTab;
  let tab2 = await addTab();

  let menuItemMoveStartTab = document.getElementById("context_moveToStart");

  gBrowser.pinTab(tab);

  updateTabContextMenu(tab2);
  is(menuItemMoveStartTab.disabled, true, "Move Tab to Start is disabled");

  BrowserTestUtils.removeTab(tab2);
  gBrowser.unpinTab(tab);
});

add_task(async function testMoveStartDisabledFromFirstPinnedTab() {
  let tab = gBrowser.selectedTab;
  let tab2 = await addTab();

  let menuItemMoveStartTab = document.getElementById("context_moveToStart");

  gBrowser.pinTab(tab);

  updateTabContextMenu(tab);
  is(menuItemMoveStartTab.disabled, true, "Move Tab to Start is disabled");

  BrowserTestUtils.removeTab(tab2);
  gBrowser.unpinTab(tab);
});

add_task(async function testMoveStartDisabledFromOnlyTab() {
  let tab = gBrowser.selectedTab;

  let menuItemMoveStartTab = document.getElementById("context_moveToStart");

  updateTabContextMenu(tab);
  is(menuItemMoveStartTab.disabled, true, "Move Tab to Start is disabled");
});

add_task(async function testMoveStartDisabledFromOnlyPinnedTab() {
  let tab = gBrowser.selectedTab;

  let menuItemMoveStartTab = document.getElementById("context_moveToStart");

  gBrowser.pinTab(tab);

  updateTabContextMenu(tab);
  is(menuItemMoveStartTab.disabled, true, "Move Tab to Start is disabled");

  gBrowser.unpinTab(tab);
});

add_task(async function testMoveStartEnabledFromLastPinnedTab() {
  let tab = gBrowser.selectedTab;
  let tab2 = await addTab();
  let tab3 = await addTab();

  let tabs = [tab2, tab3];

  let menuItemMoveStartTab = document.getElementById("context_moveToStart");

  gBrowser.pinTab(tab);
  gBrowser.pinTab(tab2);

  updateTabContextMenu(tab2);
  is(menuItemMoveStartTab.disabled, false, "Move Tab to Start is enabled");

  for (let tabToRemove of tabs) {
    BrowserTestUtils.removeTab(tabToRemove);
  }

  gBrowser.unpinTab(tab);
});

add_task(async function testMoveStartDisabledFromFirstVisibleTab() {
  let tab = gBrowser.selectedTab;
  let tab2 = await addTab();

  let menuItemMoveStartTab = document.getElementById("context_moveToStart");

  gBrowser.selectTabAtIndex(1);
  gBrowser.hideTab(tab);

  updateTabContextMenu(tab2);
  is(menuItemMoveStartTab.disabled, true, "Move Tab to Start is disabled");

  BrowserTestUtils.removeTab(tab2);
  gBrowser.showTab(tab);
});

add_task(async function testMoveEndEnabledClickedFromNonSelectedTab() {
  let tab = gBrowser.selectedTab;
  let tab2 = await addTab();
  let tab3 = await addTab();

  let tabs = [tab2, tab3];

  let menuItemMoveEndTab = document.getElementById("context_moveToEnd");

  await triggerClickOn(tab2, {});
  await triggerClickOn(tab3, { ctrlKey: true });

  ok(tab2.multiselected, "Tab2 is multiselected");
  ok(tab3.multiselected, "Tab3 is multiselected");

  updateTabContextMenu(tab);
  is(menuItemMoveEndTab.disabled, false, "Move Tab to End is enabled");

  for (let tabToRemove of tabs) {
    BrowserTestUtils.removeTab(tabToRemove);
  }
});

add_task(async function testMoveEndDisabledFromLastPinnedTab() {
  let tab = gBrowser.selectedTab;
  let tab2 = await addTab();
  let tab3 = await addTab();

  let tabs = [tab2, tab3];

  let menuItemMoveEndTab = document.getElementById("context_moveToEnd");

  gBrowser.pinTab(tab);
  gBrowser.pinTab(tab2);

  updateTabContextMenu(tab2);
  is(menuItemMoveEndTab.disabled, true, "Move Tab to End is disabled");

  for (let tabToRemove of tabs) {
    BrowserTestUtils.removeTab(tabToRemove);
  }
});

add_task(async function testMoveEndDisabledFromLastVisibleTab() {
  let tab = gBrowser.selectedTab;
  let tab2 = await addTab();

  let menuItemMoveEndTab = document.getElementById("context_moveToEnd");

  gBrowser.hideTab(tab2);

  updateTabContextMenu(tab);
  is(menuItemMoveEndTab.disabled, true, "Move Tab to End is disabled");

  BrowserTestUtils.removeTab(tab2);
  gBrowser.showTab(tab);
});

add_task(async function testMoveEndDisabledFromOnlyTab() {
  let tab = gBrowser.selectedTab;

  let menuItemMoveEndTab = document.getElementById("context_moveToEnd");

  updateTabContextMenu(tab);
  is(menuItemMoveEndTab.disabled, true, "Move Tab to End is disabled");
});

add_task(async function testMoveEndDisabledFromOnlyPinnedTab() {
  let tab = gBrowser.selectedTab;

  let menuItemMoveEndTab = document.getElementById("context_moveToEnd");

  gBrowser.pinTab(tab);

  updateTabContextMenu(tab);
  is(menuItemMoveEndTab.disabled, true, "Move Tab to End is disabled");

  gBrowser.unpinTab(tab);
});