From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../test/sidebar/browser_sidebar_switcher.js | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 browser/base/content/test/sidebar/browser_sidebar_switcher.js (limited to 'browser/base/content/test/sidebar/browser_sidebar_switcher.js') diff --git a/browser/base/content/test/sidebar/browser_sidebar_switcher.js b/browser/base/content/test/sidebar/browser_sidebar_switcher.js new file mode 100644 index 0000000000..81d7c29776 --- /dev/null +++ b/browser/base/content/test/sidebar/browser_sidebar_switcher.js @@ -0,0 +1,64 @@ +registerCleanupFunction(() => { + SidebarUI.hide(); +}); + +function showSwitcherPanelPromise() { + return new Promise(resolve => { + SidebarUI._switcherPanel.addEventListener( + "popupshown", + () => { + resolve(); + }, + { once: true } + ); + SidebarUI.showSwitcherPanel(); + }); +} + +function clickSwitcherButton(querySelector) { + let sidebarPopup = document.querySelector("#sidebarMenu-popup"); + let switcherPromise = Promise.all([ + BrowserTestUtils.waitForEvent(window, "SidebarFocused"), + BrowserTestUtils.waitForEvent(sidebarPopup, "popuphidden"), + ]); + document.querySelector(querySelector).click(); + return switcherPromise; +} + +add_task(async function () { + // If a sidebar is already open, close it. + if (!document.getElementById("sidebar-box").hidden) { + ok( + false, + "Unexpected sidebar found - a previous test failed to cleanup correctly" + ); + SidebarUI.hide(); + } + + let sidebar = document.querySelector("#sidebar-box"); + await SidebarUI.show("viewBookmarksSidebar"); + + await showSwitcherPanelPromise(); + await clickSwitcherButton("#sidebar-switcher-history"); + is( + sidebar.getAttribute("sidebarcommand"), + "viewHistorySidebar", + "History sidebar loaded" + ); + + await showSwitcherPanelPromise(); + await clickSwitcherButton("#sidebar-switcher-tabs"); + is( + sidebar.getAttribute("sidebarcommand"), + "viewTabsSidebar", + "Tabs sidebar loaded" + ); + + await showSwitcherPanelPromise(); + await clickSwitcherButton("#sidebar-switcher-bookmarks"); + is( + sidebar.getAttribute("sidebarcommand"), + "viewBookmarksSidebar", + "Bookmarks sidebar loaded" + ); +}); -- cgit v1.2.3