--- a/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger_window_open.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger_window_open.js
@@ -28,32 +28,43 @@ function withTestTabUntilStorageChange(a
ok(true, "loaded " + aPageFile);
info("running test case task");
yield* aTaskFn();
info("waiting for storage change");
yield storageChangedPromised;
});
}
+function* checkDoorhangerUsernamePassword(username, password) {
+ yield BrowserTestUtils.waitForCondition(() => {
+ return document.getElementById("password-notification-username").value == username;
+ }, "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");
+}
+
add_task(function* setup() {
yield SimpleTest.promiseFocus(window);
});
add_task(function* test_saveChromeHiddenAutoClose() {
let notifShownPromise = BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown");
// query arguments are: username, password, features, auto-close (delimited by '|')
let url = "subtst_notifications_11.html?notifyu1|notifyp1|" +
"menubar=no,toolbar=no,location=no|autoclose";
yield withTestTabUntilStorageChange(url, function*() {
info("waiting for popupshown");
yield notifShownPromise;
// the popup closes and the doorhanger should appear in the opener
let popup = getCaptureDoorhanger("password-save");
ok(popup, "got notification popup");
+ yield* checkDoorhangerUsernamePassword("notifyu1", "notifyp1");
// Sanity check, no logins should exist yet.
let logins = Services.logins.getAllLogins();
is(logins.length, 0, "Should not have any logins yet");
clickDoorhangerButton(popup, REMEMBER_BUTTON);
});
// Check result of clicking Remember
let logins = Services.logins.getAllLogins();
@@ -67,16 +78,17 @@ add_task(function* test_saveChromeHidden
add_task(function* test_changeChromeHiddenAutoClose() {
let notifShownPromise = BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown");
let url = "subtst_notifications_11.html?notifyu1|pass2|menubar=no,toolbar=no,location=no|autoclose";
yield withTestTabUntilStorageChange(url, function*() {
info("waiting for popupshown");
yield notifShownPromise;
let popup = getCaptureDoorhanger("password-change");
ok(popup, "got notification popup");
+ yield* checkDoorhangerUsernamePassword("notifyu1", "pass2");
clickDoorhangerButton(popup, CHANGE_BUTTON);
});
// Check to make sure we updated the password, timestamps and use count for
// the login being changed with this form.
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = logins[0].QueryInterface(Ci.nsILoginMetaInfo);
@@ -94,16 +106,17 @@ add_task(function* test_changeChromeHidd
add_task(function* test_saveChromeVisibleSameWindow() {
// This test actually opens a new tab in the same window with default browser settings.
let url = "subtst_notifications_11.html?notifyu2|notifyp2||";
let notifShownPromise = BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown");
yield withTestTabUntilStorageChange(url, function*() {
yield notifShownPromise;
let popup = getCaptureDoorhanger("password-save");
ok(popup, "got notification popup");
+ yield* checkDoorhangerUsernamePassword("notifyu2", "notifyp2");
clickDoorhangerButton(popup, REMEMBER_BUTTON);
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
// Check result of clicking Remember
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login now");
let login = logins[0].QueryInterface(Ci.nsILoginMetaInfo);
@@ -114,16 +127,17 @@ add_task(function* test_saveChromeVisibl
add_task(function* test_changeChromeVisibleSameWindow() {
let url = "subtst_notifications_11.html?notifyu2|pass2||";
let notifShownPromise = BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown");
yield withTestTabUntilStorageChange(url, function*() {
yield notifShownPromise;
let popup = getCaptureDoorhanger("password-change");
ok(popup, "got notification popup");
+ yield* checkDoorhangerUsernamePassword("notifyu2", "pass2");
clickDoorhangerButton(popup, CHANGE_BUTTON);
yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
// Check to make sure we updated the password, timestamps and use count for
// the login being changed with this form.
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should have 1 login");