Bug 1522521 - Port browser_bug655584 to QuantumBar. r=adw
authorMark Banner <standard8@mozilla.com>
Wed, 27 Feb 2019 08:06:12 +0000
changeset 519296 69f963484c0750fcaf37e151b5c910f7ebff9c25
parent 519295 374fbf5e2569f94d681e30ef97c9fa1cd5979c2c
child 519297 dbf19d7364137fd04c36f04086f3445c020d2c99
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1522521, 655584
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1522521 - Port browser_bug655584 to QuantumBar. r=adw Differential Revision: https://phabricator.services.mozilla.com/D21245
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_bug655584.js
browser/components/urlbar/tests/browser/browser.ini
browser/components/urlbar/tests/browser/browser_switchTab_closesUrlbarPopup.js
browser/components/urlbar/tests/legacy/browser.ini
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -201,18 +201,16 @@ skip-if = (verify && debug && (os == 'li
 [browser_bug623893.js]
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_bug624734.js]
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_bug633691.js]
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_bug647886.js]
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
-[browser_bug655584.js]
-# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_bug664672.js]
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_bug676619.js]
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_bug710878.js]
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_bug719271.js]
 skip-if = os == "win" && debug && e10s || (verify && debug && (os == 'linux')) # Bug 1315042
--- a/browser/components/urlbar/tests/browser/browser.ini
+++ b/browser/components/urlbar/tests/browser/browser.ini
@@ -39,16 +39,17 @@ subsuite = clipboard
 [browser_populateAfterPushState.js]
 [browser_redirect_error.js]
 support-files = redirect_error.sjs
 [browser_remotetab.js]
 [browser_removeUnsafeProtocolsFromURLBarPaste.js]
 subsuite = clipboard
 [browser_search_favicon.js]
 skip-if = true # Bug 1526222 - Doesn't currently work with QuantumBar
+[browser_switchTab_closesUrlbarPopup.js]
 [browser_switchToTab_closes_newtab.js]
 [browser_switchToTabHavingURI_aOpenParams.js]
 [browser_tabMatchesInAwesomebar_perwindowpb.js]
 skip-if = os == 'linux' # Bug 1104755 (Intermittent failure)
 [browser_tabMatchesInAwesomebar.js]
 support-files =
   moz.png
 [browser_urlbar_blanking.js]
rename from browser/base/content/test/general/browser_bug655584.js
rename to browser/components/urlbar/tests/browser/browser_switchTab_closesUrlbarPopup.js
--- a/browser/base/content/test/general/browser_bug655584.js
+++ b/browser/components/urlbar/tests/browser/browser_switchTab_closesUrlbarPopup.js
@@ -1,23 +1,43 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-// Bug 655584 - awesomebar suggestions don't update after tab is closed
+/**
+ * Checks that switching tabs closes the urlbar popup.
+ */
+
+"use strict";
 
 add_task(async function() {
-  var tab1 = BrowserTestUtils.addTab(gBrowser);
-  var tab2 = BrowserTestUtils.addTab(gBrowser);
+  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);
-  gURLBar.openPopup();
-  await BrowserTestUtils.switchTab(gBrowser, tab2);
-  ok(!gURLBar.popupOpen, "urlbar focused in tab to switch to, close popup");
-
-  // cleanup
-  gBrowser.removeCurrentTab();
-  gBrowser.removeCurrentTab();
+  // Now open the popup by the history marker.
+  await UrlbarTestUtils.promisePopupOpen(window, () => {
+    let historyDropMarker =
+      window.document.getAnonymousElementByAttribute(gURLBar.textbox, "anonid", "historydropmarker");
+    EventUtils.synthesizeMouseAtCenter(historyDropMarker, {}, window);
+  });
+  // 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");
 });
--- a/browser/components/urlbar/tests/legacy/browser.ini
+++ b/browser/components/urlbar/tests/legacy/browser.ini
@@ -78,16 +78,17 @@ skip-if = (os == "linux" || os == "mac")
 subsuite = clipboard
 [../browser/browser_populateAfterPushState.js]
 [../browser/browser_redirect_error.js]
 support-files = ../browser/redirect_error.sjs
 [../browser/browser_remotetab.js]
 [../browser/browser_removeUnsafeProtocolsFromURLBarPaste.js]
 subsuite = clipboard
 [../browser/browser_search_favicon.js]
+[../browser/browser_switchTab_closesUrlbarPopup.js]
 [../browser/browser_switchToTab_closes_newtab.js]
 [../browser/browser_switchToTabHavingURI_aOpenParams.js]
 [../browser/browser_tabMatchesInAwesomebar_perwindowpb.js]
 skip-if = os == 'linux' # Bug 1104755
 [../browser/browser_tabMatchesInAwesomebar.js]
 support-files =
   ../browser/moz.png
 [../browser/browser_urlbarAboutHomeLoading.js]