Bug 1530405 - Port the UITour tests to QuantumBar. r=MattN,mak.
authorMark Banner <standard8@mozilla.com>
Wed, 27 Feb 2019 16:43:56 +0000
changeset 519353 c660601ee72374ffda52fecbcf5924156ecc2f04
parent 519352 66106f6c975168680c1e5f2a4009d40d976b9f82
child 519354 08c00f2c0eaba54e7f99aa5b0024338187464e7e
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)
reviewersMattN, mak
bugs1530405
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 1530405 - Port the UITour tests to QuantumBar. r=MattN,mak. Differential Revision: https://phabricator.services.mozilla.com/D21028
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser_showMenu.js
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -26,16 +26,18 @@ ChromeUtils.defineModuleGetter(this, "Pr
 ChromeUtils.defineModuleGetter(this, "ProfileAge",
   "resource://gre/modules/ProfileAge.jsm");
 ChromeUtils.defineModuleGetter(this, "ReaderParent",
   "resource:///modules/ReaderParent.jsm");
 ChromeUtils.defineModuleGetter(this, "ResetProfile",
   "resource://gre/modules/ResetProfile.jsm");
 ChromeUtils.defineModuleGetter(this, "UpdateUtils",
   "resource://gre/modules/UpdateUtils.jsm");
+ChromeUtils.defineModuleGetter(this, "UrlbarPrefs",
+  "resource:///modules/UrlbarPrefs.jsm");
 
 // See LOG_LEVELS in Console.jsm. Common examples: "All", "Info", "Warn", & "Error".
 const PREF_LOG_LEVEL      = "browser.uitour.loglevel";
 
 const BACKGROUND_PAGE_ACTIONS_ALLOWED = new Set([
   "forceShowReaderIcon",
   "getConfiguration",
   "getTreatmentTag",
@@ -1316,32 +1318,39 @@ var UITour = {
     } else if (aMenuName == "pocket") {
       let pageAction = PageActions.actionForID("pocket");
       if (!pageAction) {
         log.error("Can't open the pocket menu without a page action");
         return;
       }
       pageAction.doCommand(aWindow);
     } else if (aMenuName == "urlbar") {
-      this.getTarget(aWindow, "urlbar").then(target => {
-        let urlbar = target.node;
-        if (aOpenCallback) {
+      let urlbar = aWindow.gURLBar;
+      let quantumbar = UrlbarPrefs.get("quantumbar");
+      if (aOpenCallback) {
+        if (quantumbar) {
+          urlbar.panel.addEventListener("popupshown", aOpenCallback, { once: true });
+        } else {
           urlbar.popup.addEventListener("popupshown", aOpenCallback, { once: true });
         }
-        urlbar.focus();
-        // To demonstrate the ability of searching, we type "Firefox" in advance
-        // for URLBar's dropdown. To limit the search results on browser-related
-        // items, we use "Firefox" hard-coded rather than l10n brandShortName
-        // entity to avoid unrelated or unpredicted results for, like, Nightly
-        // or translated entites.
-        const SEARCH_STRING = "Firefox";
-        urlbar.value = SEARCH_STRING;
-        urlbar.select();
+      }
+      urlbar.focus();
+      // To demonstrate the ability of searching, we type "Firefox" in advance
+      // for URLBar's dropdown. To limit the search results on browser-related
+      // items, we use "Firefox" hard-coded rather than l10n brandShortName
+      // entity to avoid unrelated or unpredicted results for, like, Nightly
+      // or translated entites.
+      const SEARCH_STRING = "Firefox";
+      urlbar.value = SEARCH_STRING;
+      urlbar.select();
+      if (quantumbar) {
+        urlbar.startQuery();
+      } else {
         urlbar.controller.startSearch(SEARCH_STRING);
-      }).catch(Cu.reportError);
+      }
     }
   },
 
   hideMenu(aWindow, aMenuName) {
     log.debug("hideMenu:", aMenuName);
     function closeMenuButton(aMenuBtn) {
       if (aMenuBtn && aMenuBtn.hasMenu()) {
         aMenuBtn.openMenu(false);
--- a/browser/components/uitour/test/browser_showMenu.js
+++ b/browser/components/uitour/test/browser_showMenu.js
@@ -1,13 +1,15 @@
 "use strict";
 
 const CONTROL_CENTER_PANEL = gIdentityHandler._identityPopup;
 const CONTROL_CENTER_MENU_NAME = "controlCenter";
 
+const {UrlbarTestUtils} = ChromeUtils.import("resource://testing-common/UrlbarTestUtils.jsm");
+
 var gTestTab;
 var gContentAPI;
 var gContentWindow;
 
 add_task(setup_UITourTest);
 
 add_UITour_task(async function test_showMenu_controlCenter() {
   is_element_hidden(CONTROL_CENTER_PANEL, "Panel should initially be hidden");
@@ -38,25 +40,19 @@ add_UITour_task(async function test_hide
   let hidePromise = promisePanelElementHidden(window, CONTROL_CENTER_PANEL);
   await gContentAPI.hideMenu(CONTROL_CENTER_MENU_NAME);
   await hidePromise;
 
   is_element_hidden(CONTROL_CENTER_PANEL, "Panel should hide after hideMenu");
 });
 
 add_UITour_task(async function test_showMenu_hideMenu_urlbarPopup() {
-  let shownPromise = promisePanelElementShown(window, gURLBar.popup);
-  await showMenuPromise("urlbar");
-  await shownPromise;
-  is(gURLBar.popup.state, "open", "The urlbar popup should open after showMenu");
-  is(gURLBar.controller.searchString, "Firefox", "Search string is Firefox");
-  let hidePromise = promisePanelElementHidden(window, gURLBar.popup);
-  await gContentAPI.hideMenu("urlbar");
-  await hidePromise;
-  is(gURLBar.popup.state, "closed", "The urlbar popup should close after hideMenu");
+  await UrlbarTestUtils.promisePopupOpen(window, () => showMenuPromise("urlbar"));
+  is(gURLBar.value, "Firefox", "Search string is Firefox");
+  await UrlbarTestUtils.promisePopupClose(window, () => gContentAPI.hideMenu("urlbar"));
 });
 
 add_UITour_task(async function test_showMenu_hideMenu_pageActionPanel() {
   let pageActionPanel = BrowserPageActions.panelNode;
   let shownPromise = promisePanelElementShown(window, pageActionPanel);
   await showMenuPromise("pageActionPanel");
   await shownPromise;
   is(pageActionPanel.state, "open", "The page action panel should open after showMenu");