diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/base/content/test/tabs/browser_multiselect_tabs_pin_unpin.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/tabs/browser_multiselect_tabs_pin_unpin.js')
-rw-r--r-- | browser/base/content/test/tabs/browser_multiselect_tabs_pin_unpin.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/browser/base/content/test/tabs/browser_multiselect_tabs_pin_unpin.js b/browser/base/content/test/tabs/browser_multiselect_tabs_pin_unpin.js new file mode 100644 index 0000000000..5cd71abbbe --- /dev/null +++ b/browser/base/content/test/tabs/browser_multiselect_tabs_pin_unpin.js @@ -0,0 +1,75 @@ +add_task(async function test() { + let tab1 = gBrowser.selectedTab; + let tab2 = await addTab(); + let tab3 = await addTab(); + + let menuItemPinTab = document.getElementById("context_pinTab"); + let menuItemUnpinTab = document.getElementById("context_unpinTab"); + let menuItemPinSelectedTabs = document.getElementById( + "context_pinSelectedTabs" + ); + let menuItemUnpinSelectedTabs = document.getElementById( + "context_unpinSelectedTabs" + ); + + is(gBrowser.multiSelectedTabsCount, 0, "Zero multiselected tabs"); + + await triggerClickOn(tab2, { ctrlKey: true }); + + ok(tab1.multiselected, "Tab1 is multiselected"); + ok(tab2.multiselected, "Tab2 is multiselected"); + ok(!tab3.multiselected, "Tab3 is not multiselected"); + + // Check the context menu with a non-multiselected tab + updateTabContextMenu(tab3); + ok(!tab3.pinned, "Tab3 is unpinned"); + is(menuItemPinTab.hidden, false, "Pin Tab is visible"); + is(menuItemUnpinTab.hidden, true, "Unpin Tab is hidden"); + is(menuItemPinSelectedTabs.hidden, true, "Pin Selected Tabs is hidden"); + is(menuItemUnpinSelectedTabs.hidden, true, "Unpin Selected Tabs is hidden"); + + // Check the context menu with a multiselected and unpinned tab + updateTabContextMenu(tab2); + ok(!tab2.pinned, "Tab2 is unpinned"); + is(menuItemPinTab.hidden, true, "Pin Tab is hidden"); + is(menuItemUnpinTab.hidden, true, "Unpin Tab is hidden"); + is(menuItemPinSelectedTabs.hidden, false, "Pin Selected Tabs is visible"); + is(menuItemUnpinSelectedTabs.hidden, true, "Unpin Selected Tabs is hidden"); + + let tab1Pinned = BrowserTestUtils.waitForEvent(tab1, "TabPinned"); + let tab2Pinned = BrowserTestUtils.waitForEvent(tab2, "TabPinned"); + menuItemPinSelectedTabs.click(); + await tab1Pinned; + await tab2Pinned; + + ok(tab1.pinned, "Tab1 is pinned"); + ok(tab2.pinned, "Tab2 is pinned"); + ok(!tab3.pinned, "Tab3 is unpinned"); + is(tab1._tPos, 0, "Tab1 should still be first after pinning"); + is(tab2._tPos, 1, "Tab2 should still be second after pinning"); + is(tab3._tPos, 2, "Tab3 should still be third after pinning"); + + // Check the context menu with a multiselected and pinned tab + updateTabContextMenu(tab2); + ok(tab2.pinned, "Tab2 is pinned"); + is(menuItemPinTab.hidden, true, "Pin Tab is hidden"); + is(menuItemUnpinTab.hidden, true, "Unpin Tab is hidden"); + is(menuItemPinSelectedTabs.hidden, true, "Pin Selected Tabs is hidden"); + is(menuItemUnpinSelectedTabs.hidden, false, "Unpin Selected Tabs is visible"); + + let tab1Unpinned = BrowserTestUtils.waitForEvent(tab1, "TabUnpinned"); + let tab2Unpinned = BrowserTestUtils.waitForEvent(tab2, "TabUnpinned"); + menuItemUnpinSelectedTabs.click(); + await tab1Unpinned; + await tab2Unpinned; + + ok(!tab1.pinned, "Tab1 is unpinned"); + ok(!tab2.pinned, "Tab2 is unpinned"); + ok(!tab3.pinned, "Tab3 is unpinned"); + is(tab1._tPos, 0, "Tab1 should still be first after unpinning"); + is(tab2._tPos, 1, "Tab2 should still be second after unpinning"); + is(tab3._tPos, 2, "Tab3 should still be third after unpinning"); + + BrowserTestUtils.removeTab(tab2); + BrowserTestUtils.removeTab(tab3); +}); |