Bug 1526614 - Wait when testing if notification is dismissed. r=MattN
☠☠ backed out by dede03809a93 ☠ ☠
authorSam Foster <sfoster@mozilla.com>
Tue, 12 Feb 2019 23:15:14 +0000
changeset 458819 651aa8d03082
parent 458818 de25d2f1abef
child 458820 44c507a00940
push id35548
push useropoprus@mozilla.com
push dateWed, 13 Feb 2019 09:48:26 +0000
treeherdermozilla-central@93e37c529818 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1526614
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 1526614 - Wait when testing if notification is dismissed. r=MattN Differential Revision: https://phabricator.services.mozilla.com/D19545
toolkit/components/passwordmgr/test/browser/browser_private_window.js
--- a/toolkit/components/passwordmgr/test/browser/browser_private_window.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_private_window.js
@@ -64,17 +64,17 @@ async function getResponseResult(browser
       username,
       password,
     };
   });
   return fieldValues;
 }
 
 async function waitForAuthPrompt() {
-  let promptDoc = await BrowserTestUtils.waitForCondition(() => {
+  let promptDoc = await TestUtils.waitForCondition(() => {
     return getAuthPrompt();
   });
   info("Got prompt: " + promptDoc);
   return promptDoc;
 }
 
 function getAuthPrompt() {
   let doc = getDialogDoc();
@@ -131,17 +131,18 @@ add_task(async function test_normal_popu
       "#pass": "notifyp1",
     });
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
 
     let notif = getCaptureDoorhanger("password-save", PopupNotifications, browser);
     ok(notif, "got notification popup");
     if (notif) {
-      ok(!notif.wasDismissed, "notification should not be dismissed");
+      await TestUtils.waitForCondition(() => !notif.dismissed,
+                                       "notification should not be dismissed");
       notif.remove();
     }
   });
 });
 
 add_task(async function test_private_popup_notification_2() {
   info("test 2: run inside of private mode, dismissed popup notification should appear");
 
@@ -160,17 +161,18 @@ add_task(async function test_private_pop
       "#pass": "notifyp1",
     });
     is(fieldValues.username, "notifyu1", "Checking submitted username");
     is(fieldValues.password, "notifyp1", "Checking submitted password");
 
     let notif = getCaptureDoorhanger("password-save", PopupNotifications, browser);
     ok(notif, "Expected notification popup");
     if (notif) {
-      ok(notif.wasDismissed, "notification should be dismissed");
+      await TestUtils.waitForCondition(() => notif.dismissed,
+                                       "notification should be dismissed");
       notif.remove();
     }
   });
   is(Services.logins.getAllLogins().length, 0, "No logins were saved");
 });
 
 add_task(async function test_private_popup_notification_no_capture_pref_2b() {
   info("test 2b: run inside of private mode, with capture pref off," +
@@ -291,17 +293,18 @@ add_task(async function test_normal_new_
     let fieldValues = await submitForm(browser, "formsubmit.sjs", {
       "#pass": "notifyp1",
       "#newpass": "notifyp2",
     });
     is(fieldValues.password, "notifyp1", "Checking submitted password");
     let notif = getCaptureDoorhanger("password-change", PopupNotifications, browser);
     ok(notif, "got notification popup");
     if (notif) {
-      ok(!notif.wasDismissed, "notification should not be dismissed");
+      await TestUtils.waitForCondition(() => !notif.dismissed,
+                                       "notification should not be dismissed");
       notif.remove();
     }
   });
   // We put up a doorhanger, but didn't interact with it, so we expect the login timestamps
   // to be unchanged
   allLogins = Services.logins.getAllLogins();
   is(allLogins[0].guid, loginGuid, "Sanity-check we are comparing the same login record");
   is(allLogins[0].timeLastUsed, timeLastUsed, "The timeLastUsed timestamp was not updated");
@@ -327,17 +330,18 @@ add_task(async function test_private_new
     let fieldValues = await submitForm(browser, "formsubmit.sjs", {
       "#pass": "notifyp1",
       "#newpass": "notifyp2",
     });
     is(fieldValues.password, "notifyp1", "Checking submitted password");
     let notif = getCaptureDoorhanger("password-change", PopupNotifications, browser);
     ok(notif, "Expected notification popup");
     if (notif) {
-      ok(!notif.wasDismissed, "notification should not be dismissed");
+      await TestUtils.waitForCondition(() => !notif.dismissed,
+                                       "notification should not be dismissed");
       notif.remove();
     }
   });
   // We put up a doorhanger, but didn't interact with it, so we expect the login timestamps
   // to be unchanged
   allLogins = Services.logins.getAllLogins();
   is(allLogins[0].guid, loginGuid, "Sanity-check we are comparing the same login record");
   is(allLogins[0].timeLastUsed, timeLastUsed, "The timeLastUsed timestamp has not been updated");
@@ -354,17 +358,18 @@ add_task(async function test_normal_with
     let fieldValues = await submitForm(browser, "formsubmit.sjs", {
       "#pass": "notifyp1",
       "#newpass": "notifyp2",
     });
     is(fieldValues.password, "notifyp1", "Checking submitted password");
     let notif = getCaptureDoorhanger("password-change", PopupNotifications, browser);
     ok(notif, "got notification popup");
     if (notif) {
-      ok(!notif.wasDismissed, "notification should not be dismissed");
+      await TestUtils.waitForCondition(() => !notif.dismissed,
+                                       "notification should not be dismissed");
       notif.remove();
     }
     Services.logins.removeLogin(login);
   });
 });
 
 add_task(async function test_normal_autofilled_7() {
   info("test 7: verify that the user/pass pair was autofilled");
@@ -490,17 +495,18 @@ add_task(async function test_normal_http
     });
     is(fieldValues.ok, "PASS", "Checking authorization passed");
     is(fieldValues.username, "test", "Checking authorized username");
     is(fieldValues.password, "testpass", "Checking authorized password");
 
     let notif = getCaptureDoorhanger("password-save", PopupNotifications, browser);
     ok(notif, "got notification popup");
     if (notif) {
-      ok(!notif.wasDismissed, "notification should not be dismissed");
+      await TestUtils.waitForCondition(() => !notif.dismissed,
+                                       "notification should not be dismissed");
       notif.remove();
     }
   });
 });
 
 add_task(async function test_private_http_basic_auth() {
   info("test private/basic-auth: verify that we don't get a doorhanger after basic-auth login");
   Services.logins.removeAllLogins();
@@ -516,17 +522,18 @@ add_task(async function test_private_htt
     await loadAccessRestrictedURL(browser, authUrl, "test", "testpass");
     let fieldValues = await getResponseResult(browser, "authenticate.sjs");
     is(fieldValues.username, "test", "Checking authorized username");
     is(fieldValues.password, "testpass", "Checking authorized password");
 
     let notif = getCaptureDoorhanger("password-save", PopupNotifications, browser);
     ok(notif, "got notification popup");
     if (notif) {
-      ok(notif.wasDismissed, "notification should be dismissed");
+      await TestUtils.waitForCondition(() => notif.dismissed,
+                                       "notification should be dismissed");
       notif.remove();
     }
   });
 });
 
 add_task(async function test_private_http_basic_auth_no_capture_pref() {
   info("test private/basic-auth: verify that we don't get a doorhanger after basic-auth login" +
        "with capture pref off");