summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_panel_locationSpecific.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/customizableui/test/browser_panel_locationSpecific.js')
-rw-r--r--browser/components/customizableui/test/browser_panel_locationSpecific.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/browser/components/customizableui/test/browser_panel_locationSpecific.js b/browser/components/customizableui/test/browser_panel_locationSpecific.js
new file mode 100644
index 0000000000..1668751d9f
--- /dev/null
+++ b/browser/components/customizableui/test/browser_panel_locationSpecific.js
@@ -0,0 +1,78 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/*
+ * This test creates multiple panels, one that has been tagged as location specific
+ * and one that isn't. When the location changes, the specific panel should close.
+ * The non-specific panel should remain open.
+ *
+ */
+
+add_task(async function () {
+ let specificPanel = document.createXULElement("panel");
+ specificPanel.setAttribute("locationspecific", "true");
+ specificPanel.setAttribute("noautohide", "true");
+ specificPanel.style.height = "100px";
+ specificPanel.style.width = "100px";
+
+ let generalPanel = document.createXULElement("panel");
+ generalPanel.setAttribute("noautohide", "true");
+ generalPanel.style.height = "100px";
+ generalPanel.style.width = "100px";
+
+ let anchor = document.getElementById(CustomizableUI.AREA_NAVBAR);
+
+ anchor.appendChild(specificPanel);
+ anchor.appendChild(generalPanel);
+ is(specificPanel.state, "closed", "specificPanel starts as closed");
+ is(generalPanel.state, "closed", "generalPanel starts as closed");
+
+ let specificPanelPromise = BrowserTestUtils.waitForEvent(
+ specificPanel,
+ "popupshown"
+ );
+
+ specificPanel.openPopupAtScreen(0, 0);
+
+ await specificPanelPromise;
+ is(specificPanel.state, "open", "specificPanel has been opened");
+
+ let generalPanelPromise = BrowserTestUtils.waitForEvent(
+ generalPanel,
+ "popupshown"
+ );
+
+ generalPanel.openPopupAtScreen(100, 0);
+
+ await generalPanelPromise;
+ is(generalPanel.state, "open", "generalPanel has been opened");
+
+ let specificPanelHiddenPromise = BrowserTestUtils.waitForEvent(
+ specificPanel,
+ "popuphidden"
+ );
+
+ // Simulate a location change, and check which panel closes.
+ let browser = gBrowser.selectedBrowser;
+ let loaded = BrowserTestUtils.browserLoaded(browser);
+ BrowserTestUtils.loadURIString(browser, "http://mochi.test:8888/#0");
+ await loaded;
+
+ await specificPanelHiddenPromise;
+
+ is(
+ specificPanel.state,
+ "closed",
+ "specificPanel panel is closed after location change"
+ );
+ is(
+ generalPanel.state,
+ "open",
+ "generalPanel is still open after location change"
+ );
+
+ specificPanel.remove();
+ generalPanel.remove();
+});