diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/base/content/test/tabs/browser_tab_manager_close.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/base/content/test/tabs/browser_tab_manager_close.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/browser/base/content/test/tabs/browser_tab_manager_close.js b/browser/base/content/test/tabs/browser_tab_manager_close.js new file mode 100644 index 0000000000..d04b2a6c0a --- /dev/null +++ b/browser/base/content/test/tabs/browser_tab_manager_close.js @@ -0,0 +1,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); +}); |