summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/browser/browser_switchTab_closesUrlbarPopup.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/urlbar/tests/browser/browser_switchTab_closesUrlbarPopup.js')
-rw-r--r--browser/components/urlbar/tests/browser/browser_switchTab_closesUrlbarPopup.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/browser/components/urlbar/tests/browser/browser_switchTab_closesUrlbarPopup.js b/browser/components/urlbar/tests/browser/browser_switchTab_closesUrlbarPopup.js
new file mode 100644
index 0000000000..a9b0eb7b1a
--- /dev/null
+++ b/browser/components/urlbar/tests/browser/browser_switchTab_closesUrlbarPopup.js
@@ -0,0 +1,42 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/**
+ * Checks that switching tabs closes the urlbar popup.
+ */
+
+"use strict";
+
+add_task(async function () {
+ let tab1 = BrowserTestUtils.addTab(gBrowser);
+ let tab2 = BrowserTestUtils.addTab(gBrowser);
+
+ registerCleanupFunction(async () => {
+ await PlacesUtils.history.clear();
+ BrowserTestUtils.removeTab(tab1);
+ BrowserTestUtils.removeTab(tab2);
+ });
+
+ // Add a couple of dummy entries to ensure the history popup will open.
+ await PlacesTestUtils.addVisits([
+ { uri: makeURI("http://example.com/foo") },
+ { uri: makeURI("http://example.com/foo/bar") },
+ ]);
+
+ // When urlbar in a new tab is focused, and a tab switch occurs,
+ // the urlbar popup should be closed
+ await BrowserTestUtils.switchTab(gBrowser, tab2);
+ gURLBar.focus(); // focus the urlbar in the tab we will switch to
+ await BrowserTestUtils.switchTab(gBrowser, tab1);
+ // Now open the popup.
+ await UrlbarTestUtils.promiseAutocompleteResultPopup({
+ window,
+ value: "",
+ });
+ // Check that the popup closes when we switch tab.
+ await UrlbarTestUtils.promisePopupClose(window, () => {
+ return BrowserTestUtils.switchTab(gBrowser, tab2);
+ });
+ Assert.ok(true, "Popup was successfully closed");
+});