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_using_Ctrl.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_using_Ctrl.js')
-rw-r--r-- | browser/base/content/test/tabs/browser_multiselect_tabs_using_Ctrl.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/browser/base/content/test/tabs/browser_multiselect_tabs_using_Ctrl.js b/browser/base/content/test/tabs/browser_multiselect_tabs_using_Ctrl.js new file mode 100644 index 0000000000..93a14a87a7 --- /dev/null +++ b/browser/base/content/test/tabs/browser_multiselect_tabs_using_Ctrl.js @@ -0,0 +1,60 @@ +add_task(async function click() { + const initialFocusedTab = await addTab(); + await BrowserTestUtils.switchTab(gBrowser, initialFocusedTab); + const tab = await addTab(); + + await triggerClickOn(tab, { ctrlKey: true }); + ok( + tab.multiselected && gBrowser._multiSelectedTabsSet.has(tab), + "Tab should be (multi) selected after click" + ); + isnot(gBrowser.selectedTab, tab, "Multi-selected tab is not focused"); + is(gBrowser.selectedTab, initialFocusedTab, "Focused tab doesn't change"); + + await triggerClickOn(tab, { ctrlKey: true }); + ok( + !tab.multiselected && !gBrowser._multiSelectedTabsSet.has(tab), + "Tab is not (multi) selected anymore" + ); + is( + gBrowser.selectedTab, + initialFocusedTab, + "Focused tab still doesn't change" + ); + + BrowserTestUtils.removeTab(initialFocusedTab); + BrowserTestUtils.removeTab(tab); +}); + +add_task(async function clearSelection() { + const tab1 = await addTab(); + const tab2 = await addTab(); + const tab3 = await addTab(); + + await BrowserTestUtils.switchTab(gBrowser, tab1); + info("We multi-select tab2 with ctrl key down"); + await triggerClickOn(tab2, { ctrlKey: true }); + + ok( + tab1.multiselected && gBrowser._multiSelectedTabsSet.has(tab1), + "Tab1 is (multi) selected" + ); + ok( + tab2.multiselected && gBrowser._multiSelectedTabsSet.has(tab2), + "Tab2 is (multi) selected" + ); + is(gBrowser.multiSelectedTabsCount, 2, "Two tabs (multi) selected"); + isnot(tab3, gBrowser.selectedTab, "Tab3 doesn't have focus"); + + info("We select tab3 with Ctrl key up"); + await triggerClickOn(tab3, { ctrlKey: false }); + + ok(!tab1.multiselected, "Tab1 is not (multi) selected"); + ok(!tab2.multiselected, "Tab2 is not (multi) selected"); + is(gBrowser.multiSelectedTabsCount, 0, "Multi-selection is cleared"); + is(tab3, gBrowser.selectedTab, "Tab3 has focus"); + + BrowserTestUtils.removeTab(tab1); + BrowserTestUtils.removeTab(tab2); + BrowserTestUtils.removeTab(tab3); +}); |