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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const URL1 = "data:text/plain,tab1";
const URL2 = "data:text/plain,tab2";
const URL3 = "data:text/plain,tab3";
const URL4 = "data:text/plain,tab4";
const URL5 = "data:text/plain,tab5";
add_setup(async function () {
await SpecialPowers.pushPrefEnv({
set: [["browser.tabs.tabmanager.enabled", true]],
});
});
/**
* Tests that middle-clicking on a tab in the Tab Manager will close it.
*/
add_task(async function test_tab_manager_close_middle_click() {
let win =
await BrowserTestUtils.openNewWindowWithFlushedCacheForMozSupports();
win.gTabsPanel.init();
await addTabTo(win.gBrowser, URL1);
await addTabTo(win.gBrowser, URL2);
await addTabTo(win.gBrowser, URL3);
await addTabTo(win.gBrowser, URL4);
await addTabTo(win.gBrowser, URL5);
let button = win.document.getElementById("alltabs-button");
let allTabsView = win.document.getElementById("allTabsMenu-allTabsView");
let allTabsPopupShownPromise = BrowserTestUtils.waitForEvent(
allTabsView,
"ViewShown"
);
button.click();
await allTabsPopupShownPromise;
let list = win.document.getElementById("allTabsMenu-allTabsView-tabs");
while (win.gBrowser.tabs.length > 1) {
let row = list.lastElementChild;
let tabClosing = BrowserTestUtils.waitForTabClosing(row.tab);
EventUtils.synthesizeMouseAtCenter(row, { button: 1 }, win);
await tabClosing;
Assert.ok(true, "Closed a tab with middle-click.");
}
await BrowserTestUtils.closeWindow(win);
});
/**
* Tests that clicking the close button next to a tab manager item
* will close it.
*/
add_task(async function test_tab_manager_close_button() {
let win =
await BrowserTestUtils.openNewWindowWithFlushedCacheForMozSupports();
win.gTabsPanel.init();
await addTabTo(win.gBrowser, URL1);
await addTabTo(win.gBrowser, URL2);
await addTabTo(win.gBrowser, URL3);
await addTabTo(win.gBrowser, URL4);
await addTabTo(win.gBrowser, URL5);
let button = win.document.getElementById("alltabs-button");
let allTabsView = win.document.getElementById("allTabsMenu-allTabsView");
let allTabsPopupShownPromise = BrowserTestUtils.waitForEvent(
allTabsView,
"ViewShown"
);
button.click();
await allTabsPopupShownPromise;
let list = win.document.getElementById("allTabsMenu-allTabsView-tabs");
while (win.gBrowser.tabs.length > 1) {
let row = list.lastElementChild;
let tabClosing = BrowserTestUtils.waitForTabClosing(row.tab);
let closeButton = row.lastElementChild;
EventUtils.synthesizeMouseAtCenter(closeButton, { button: 1 }, win);
await tabClosing;
Assert.ok(true, "Closed a tab with the close button.");
}
await BrowserTestUtils.closeWindow(win);
});
|