Bug 1530603 - Wait for #filter in browser_autocomplete_footer.js. r=intermittent, a=test-only
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 27 Mar 2019 23:03:57 -0700
changeset 525772 6b273123543412fa98b0c551863efb7d8270bf2e
parent 525771 3c19646ca2d05508dddd236d6ada2611eeecbcad
child 525773 9b874010673d878cb9772770bc8ba7f6572ee693
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersintermittent, test-only
bugs1530603
milestone67.0
Bug 1530603 - Wait for #filter in browser_autocomplete_footer.js. r=intermittent, a=test-only
toolkit/components/passwordmgr/test/browser/browser_autocomplete_footer.js
toolkit/components/passwordmgr/test/browser/browser_openPasswordManager.js
toolkit/components/passwordmgr/test/browser/head.js
--- a/toolkit/components/passwordmgr/test/browser/browser_autocomplete_footer.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_autocomplete_footer.js
@@ -66,22 +66,19 @@ add_task(async function test_autocomplet
     let footer = popup.querySelector(`[originaltype="loginsFooter"]`);
     ok(footer, "Got footer richlistitem");
 
     await TestUtils.waitForCondition(() => {
       return !EventUtils.isHidden(footer);
     }, "Waiting for footer to become visible");
 
     EventUtils.synthesizeMouseAtCenter(footer, {});
-    await TestUtils.waitForCondition(() => {
-      return Services.wm.getMostRecentWindow("Toolkit:PasswordManager") !== null;
-    }, "Waiting for the password manager dialog to open");
+    let window = await waitForPasswordManagerDialog();
     info("Login dialog was opened");
 
-    let window = Services.wm.getMostRecentWindow("Toolkit:PasswordManager");
     await TestUtils.waitForCondition(() => {
       return window.document.getElementById("filter").value == "example.com";
     }, "Waiting for the search string to filter logins");
 
     window.close();
     popup.hidePopup();
   });
 });
@@ -104,22 +101,19 @@ add_task(async function test_autocomplet
       return !EventUtils.isHidden(footer);
     }, "Waiting for footer to become visible");
 
     await EventUtils.synthesizeKey("KEY_ArrowDown");
     await EventUtils.synthesizeKey("KEY_ArrowDown");
     await EventUtils.synthesizeKey("KEY_ArrowDown");
     await EventUtils.synthesizeKey("KEY_Enter");
 
-    await TestUtils.waitForCondition(() => {
-      return Services.wm.getMostRecentWindow("Toolkit:PasswordManager") !== null;
-    }, "Waiting for the password manager dialog to open");
+    let window = await waitForPasswordManagerDialog();
     info("Login dialog was opened");
 
-    let window = Services.wm.getMostRecentWindow("Toolkit:PasswordManager");
     await TestUtils.waitForCondition(() => {
       return window.document.getElementById("filter").value == "example.com";
     }, "Waiting for the search string to filter logins");
 
     window.close();
     popup.hidePopup();
   });
 });
--- a/toolkit/components/passwordmgr/test/browser/browser_openPasswordManager.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_openPasswordManager.js
@@ -3,35 +3,29 @@ const PREF_MANAGEMENT_URI = "signon.mana
 function resetPrefs() {
   Services.prefs.clearUserPref(PREF_MANAGEMENT_URI);
 }
 
 registerCleanupFunction(resetPrefs);
 
 add_task(async function test_noFilter() {
   LoginHelper.openPasswordManager(window);
-  await TestUtils.waitForCondition(() => {
-    return Services.wm.getMostRecentWindow("Toolkit:PasswordManager") !== null;
-  }, "Waiting for the password manager dialog to open");
-  let win = Services.wm.getMostRecentWindow("Toolkit:PasswordManager");
+  let win = await waitForPasswordManagerDialog();
   ok(win, "Login dialog was opened");
   await BrowserTestUtils.closeWindow(win);
   await TestUtils.waitForCondition(() => {
     return Services.wm.getMostRecentWindow("Toolkit:PasswordManager") === null;
   }, "Waiting for the password manager dialog to close");
 });
 
 add_task(async function test_filter() {
   // Greek IDN for example.test
   let domain = "παράδειγμα.δοκιμή";
   LoginHelper.openPasswordManager(window, domain);
-  await TestUtils.waitForCondition(() => {
-    return Services.wm.getMostRecentWindow("Toolkit:PasswordManager") !== null;
-  }, "Waiting for the password manager dialog to open");
-  let win = Services.wm.getMostRecentWindow("Toolkit:PasswordManager");
+  let win = await waitForPasswordManagerDialog();
   await TestUtils.waitForCondition(() => {
     return win.document.getElementById("filter").value == domain;
   }, "Waiting for the search string to filter logins");
   ok(win, "Login dialog was opened with a domain filter");
   await BrowserTestUtils.closeWindow(win);
   await TestUtils.waitForCondition(() => {
     return Services.wm.getMostRecentWindow("Toolkit:PasswordManager") === null;
   }, "Waiting for the password manager dialog to close");
--- a/toolkit/components/passwordmgr/test/browser/head.js
+++ b/toolkit/components/passwordmgr/test/browser/head.js
@@ -149,8 +149,18 @@ async function checkDoorhangerUsernamePa
   }, "Wait for nsLoginManagerPrompter writeDataToUI()");
   is(document.getElementById("password-notification-username").value, username,
      "Check doorhanger username");
   is(document.getElementById("password-notification-password").value, password,
      "Check doorhanger password");
 }
 
 // End popup notification (doorhanger) functions //
+
+async function waitForPasswordManagerDialog() {
+  let win;
+  await TestUtils.waitForCondition(() => {
+    win = Services.wm.getMostRecentWindow("Toolkit:PasswordManager");
+    return win && win.document.getElementById("filter");
+  }, "Waiting for the password manager dialog to open");
+
+  return win;
+}