From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/tabs/browser_multiselect_tabs_bookmark.js | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 browser/base/content/test/tabs/browser_multiselect_tabs_bookmark.js (limited to 'browser/base/content/test/tabs/browser_multiselect_tabs_bookmark.js') diff --git a/browser/base/content/test/tabs/browser_multiselect_tabs_bookmark.js b/browser/base/content/test/tabs/browser_multiselect_tabs_bookmark.js new file mode 100644 index 0000000000..a24e72c0bb --- /dev/null +++ b/browser/base/content/test/tabs/browser_multiselect_tabs_bookmark.js @@ -0,0 +1,81 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +async function addTab_example_com() { + // eslint-disable-next-line @microsoft/sdl/no-insecure-url + const tab = BrowserTestUtils.addTab(gBrowser, "http://example.com/", { + skipAnimation: true, + }); + const browser = gBrowser.getBrowserForTab(tab); + await BrowserTestUtils.browserLoaded(browser); + return tab; +} + +add_task(async function test() { + let tab1 = await addTab(); + let tab2 = await addTab(); + let tab3 = await addTab(); + + let menuItemBookmarkTab = document.getElementById("context_bookmarkTab"); + let menuItemBookmarkSelectedTabs = document.getElementById( + "context_bookmarkSelectedTabs" + ); + + is(gBrowser.multiSelectedTabsCount, 0, "Zero multiselected tabs"); + + await BrowserTestUtils.switchTab(gBrowser, tab1); + 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); + is(menuItemBookmarkTab.hidden, false, "Bookmark Tab is visible"); + is( + menuItemBookmarkSelectedTabs.hidden, + true, + "Bookmark Selected Tabs is hidden" + ); + + // Check the context menu with a multiselected tab and one unique page in the selection. + updateTabContextMenu(tab2); + is(menuItemBookmarkTab.hidden, true, "Bookmark Tab is visible"); + is( + menuItemBookmarkSelectedTabs.hidden, + false, + "Bookmark Selected Tabs is hidden" + ); + is( + PlacesCommandHook.uniqueSelectedPages.length, + 1, + "No more than one unique selected page" + ); + + info("Add a different page to selection"); + let tab4 = await addTab_example_com(); + await triggerClickOn(tab4, { ctrlKey: true }); + + ok(tab4.multiselected, "Tab4 is multiselected"); + is(gBrowser.multiSelectedTabsCount, 3, "Three multiselected tabs"); + + // Check the context menu with a multiselected tab and two unique pages in the selection. + updateTabContextMenu(tab2); + is(menuItemBookmarkTab.hidden, true, "Bookmark Tab is visible"); + is( + menuItemBookmarkSelectedTabs.hidden, + false, + "Bookmark Selected Tabs is hidden" + ); + is( + PlacesCommandHook.uniqueSelectedPages.length, + 2, + "More than one unique selected page" + ); + + for (let tab of [tab1, tab2, tab3, tab4]) { + BrowserTestUtils.removeTab(tab); + } +}); -- cgit v1.2.3