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_drag_to_bookmarks_toolbar.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 '')
-rw-r--r-- | browser/base/content/test/tabs/browser_multiselect_tabs_drag_to_bookmarks_toolbar.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/browser/base/content/test/tabs/browser_multiselect_tabs_drag_to_bookmarks_toolbar.js b/browser/base/content/test/tabs/browser_multiselect_tabs_drag_to_bookmarks_toolbar.js new file mode 100644 index 0000000000..42342c889c --- /dev/null +++ b/browser/base/content/test/tabs/browser_multiselect_tabs_drag_to_bookmarks_toolbar.js @@ -0,0 +1,74 @@ +add_task(async function test() { + // Disable tab animations + gReduceMotionOverride = true; + + // Open Bookmarks Toolbar + let bookmarksToolbar = document.getElementById("PersonalToolbar"); + setToolbarVisibility(bookmarksToolbar, true); + ok(!bookmarksToolbar.collapsed, "bookmarksToolbar should be visible now"); + + let tab1 = await addTab("http://mochi.test:8888/1"); + let tab2 = await addTab("http://mochi.test:8888/2"); + let tab3 = await addTab("http://mochi.test:8888/3"); + let tab4 = await addTab("http://mochi.test:8888/4"); + let tab5 = await addTab("http://mochi.test:8888/5"); + + is(gBrowser.multiSelectedTabsCount, 0, "Zero multiselected tabs"); + + await BrowserTestUtils.switchTab(gBrowser, tab2); + await triggerClickOn(tab1, { ctrlKey: true }); + + ok(tab1.multiselected, "Tab1 is multiselected"); + ok(tab2.multiselected, "Tab2 is multiselected"); + ok(!tab3.multiselected, "Tab3 is not multiselected"); + ok(!tab4.multiselected, "Tab4 is not multiselected"); + ok(!tab5.multiselected, "Tab5 is not multiselected"); + is(gBrowser.multiSelectedTabsCount, 2, "Two multiselected tabs"); + + // Use getElementsByClassName so the list is live and will update as items change. + let currentBookmarks = + bookmarksToolbar.getElementsByClassName("bookmark-item"); + let startBookmarksLength = currentBookmarks.length; + + // The destination element should be a non-folder bookmark + let destBookmarkItem = () => + bookmarksToolbar.querySelector( + "#PlacesToolbarItems .bookmark-item:not([container])" + ); + + await EventUtils.synthesizePlainDragAndDrop({ + srcElement: tab1, + destElement: destBookmarkItem(), + }); + await TestUtils.waitForCondition( + () => currentBookmarks.length == startBookmarksLength + 2, + "waiting for 2 bookmarks" + ); + is( + currentBookmarks.length, + startBookmarksLength + 2, + "Bookmark count should have increased by 2" + ); + + // Drag non-selection to the bookmarks toolbar + startBookmarksLength = currentBookmarks.length; + await EventUtils.synthesizePlainDragAndDrop({ + srcElement: tab3, + destElement: destBookmarkItem(), + }); + await TestUtils.waitForCondition( + () => currentBookmarks.length == startBookmarksLength + 1, + "waiting for 1 bookmark" + ); + is( + currentBookmarks.length, + startBookmarksLength + 1, + "Bookmark count should have increased by 1" + ); + + BrowserTestUtils.removeTab(tab1); + BrowserTestUtils.removeTab(tab2); + BrowserTestUtils.removeTab(tab3); + BrowserTestUtils.removeTab(tab4); + BrowserTestUtils.removeTab(tab5); +}); |