summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_sidebar_toggle.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /browser/components/customizableui/test/browser_sidebar_toggle.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/customizableui/test/browser_sidebar_toggle.js')
-rw-r--r--browser/components/customizableui/test/browser_sidebar_toggle.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/browser/components/customizableui/test/browser_sidebar_toggle.js b/browser/components/customizableui/test/browser_sidebar_toggle.js
new file mode 100644
index 0000000000..0ded5ec7ad
--- /dev/null
+++ b/browser/components/customizableui/test/browser_sidebar_toggle.js
@@ -0,0 +1,58 @@
+/* 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/. */
+
+"use strict";
+
+registerCleanupFunction(async function() {
+ await resetCustomization();
+
+ // Ensure sidebar is hidden after each test:
+ if (!document.getElementById("sidebar-box").hidden) {
+ SidebarUI.hide();
+ }
+});
+
+var showSidebar = async function(win = window) {
+ let button = win.document.getElementById("sidebar-button");
+ let sidebarFocusedPromise = BrowserTestUtils.waitForEvent(
+ win.document,
+ "SidebarFocused"
+ );
+ EventUtils.synthesizeMouseAtCenter(button, {}, win);
+ await sidebarFocusedPromise;
+ ok(win.SidebarUI.isOpen, "Sidebar is opened");
+ ok(button.hasAttribute("checked"), "Toolbar button is checked");
+};
+
+var hideSidebar = async function(win = window) {
+ let button = win.document.getElementById("sidebar-button");
+ EventUtils.synthesizeMouseAtCenter(button, {}, win);
+ ok(!win.SidebarUI.isOpen, "Sidebar is closed");
+ ok(!button.hasAttribute("checked"), "Toolbar button isn't checked");
+};
+
+// Check the sidebar widget shows the default items
+add_task(async function() {
+ CustomizableUI.addWidgetToArea("sidebar-button", "nav-bar");
+
+ await showSidebar();
+ is(SidebarUI.currentID, "viewBookmarksSidebar", "Default sidebar selected");
+ await SidebarUI.show("viewHistorySidebar");
+
+ await hideSidebar();
+ await showSidebar();
+ is(SidebarUI.currentID, "viewHistorySidebar", "Selected sidebar remembered");
+
+ await hideSidebar();
+ let otherWin = await BrowserTestUtils.openNewBrowserWindow();
+ await showSidebar(otherWin);
+ is(
+ otherWin.SidebarUI.currentID,
+ "viewHistorySidebar",
+ "Selected sidebar remembered across windows"
+ );
+ await hideSidebar(otherWin);
+
+ await BrowserTestUtils.closeWindow(otherWin);
+});