зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1560042 - Part 1: Share verifyLogins test helper, new cleanupDoorhanger helper. r=MattN
Differential Revision: https://phabricator.services.mozilla.com/D41083 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8ed12296ff
Коммит
1dc7c92128
|
@ -66,14 +66,14 @@ add_task(async function setup() {
|
|||
});
|
||||
|
||||
add_task(async function test_remember_opens() {
|
||||
await testSubmittingLoginForm("subtst_notifications_1.html", function(
|
||||
await testSubmittingLoginForm("subtst_notifications_1.html", async function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -83,7 +83,7 @@ add_task(async function test_clickNever() {
|
|||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
is(
|
||||
true,
|
||||
|
@ -93,6 +93,7 @@ add_task(async function test_clickNever() {
|
|||
|
||||
await checkDoorhangerUsernamePassword("notifyu1", "notifyp1");
|
||||
clickDoorhangerButton(notif, NEVER_MENUITEM);
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
|
||||
is(
|
||||
|
@ -130,7 +131,7 @@ add_task(async function test_clickRemember() {
|
|||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
|
||||
is(
|
||||
|
@ -178,6 +179,7 @@ add_task(async function test_clickRemember() {
|
|||
|
||||
// remove that login
|
||||
Services.logins.removeLogin(login1);
|
||||
await cleanupDoorhanger();
|
||||
});
|
||||
|
||||
/* signons.rememberSignons pref tests... */
|
||||
|
@ -206,14 +208,14 @@ add_task(async function test_rememberSignonsTrue() {
|
|||
info("Make sure we prompt with rememberSignons=true");
|
||||
Services.prefs.setBoolPref("signon.rememberSignons", true);
|
||||
|
||||
await testSubmittingLoginForm("subtst_notifications_1.html", function(
|
||||
await testSubmittingLoginForm("subtst_notifications_1.html", async function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
|
||||
is(
|
||||
|
@ -230,14 +232,14 @@ add_task(async function test_autocompleteOffUsername() {
|
|||
"Check for notification popup when autocomplete=off present on username"
|
||||
);
|
||||
|
||||
await testSubmittingLoginForm("subtst_notifications_2.html", function(
|
||||
await testSubmittingLoginForm("subtst_notifications_2.html", async function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "checking for notification popup");
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
|
||||
is(
|
||||
|
@ -252,14 +254,14 @@ add_task(async function test_autocompleteOffPassword() {
|
|||
"Check for notification popup when autocomplete=off present on password"
|
||||
);
|
||||
|
||||
await testSubmittingLoginForm("subtst_notifications_3.html", function(
|
||||
await testSubmittingLoginForm("subtst_notifications_3.html", async function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "checking for notification popup");
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
|
||||
is(
|
||||
|
@ -272,14 +274,14 @@ add_task(async function test_autocompleteOffPassword() {
|
|||
add_task(async function test_autocompleteOffForm() {
|
||||
info("Check for notification popup when autocomplete=off present on form");
|
||||
|
||||
await testSubmittingLoginForm("subtst_notifications_4.html", function(
|
||||
await testSubmittingLoginForm("subtst_notifications_4.html", async function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "checking for notification popup");
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
|
||||
is(
|
||||
|
@ -317,7 +319,7 @@ add_task(async function test_pwOnlyNewLoginMatchesUPForm() {
|
|||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "checking for notification popup");
|
||||
is(
|
||||
notif.message,
|
||||
|
@ -371,7 +373,7 @@ add_task(async function test_pwOnlyOldLoginMatchesUPForm() {
|
|||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "checking for notification popup");
|
||||
is(
|
||||
notif.message,
|
||||
|
@ -432,14 +434,14 @@ add_task(async function test_pwOnlyFormDoesntMatchExisting() {
|
|||
);
|
||||
Services.logins.addLogin(login1B);
|
||||
|
||||
await testSubmittingLoginForm("subtst_notifications_6.html", function(
|
||||
await testSubmittingLoginForm("subtst_notifications_6.html", async function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "null", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
|
||||
let logins = Services.logins.getAllLogins();
|
||||
|
@ -461,7 +463,7 @@ add_task(async function test_changeUPLoginOnUPForm_dont() {
|
|||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "pass2", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "got notification popup");
|
||||
is(notif.message, "Would you like to update this login?", "Check message");
|
||||
|
||||
|
@ -488,7 +490,7 @@ add_task(async function test_changeUPLoginOnUPForm_change() {
|
|||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "pass2", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "got notification popup");
|
||||
is(notif.message, "Would you like to update this login?", "Check message");
|
||||
|
||||
|
@ -522,7 +524,7 @@ add_task(async function test_changePLoginOnUPForm() {
|
|||
) {
|
||||
is(fieldValues.username, "", "Checking submitted username");
|
||||
is(fieldValues.password, "pass2", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "got notification popup");
|
||||
is(notif.message, "Would you like to update this password?", "Check msg");
|
||||
|
||||
|
@ -550,7 +552,7 @@ add_task(async function test_changePLoginOnPForm() {
|
|||
) {
|
||||
is(fieldValues.username, "null", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "got notification popup");
|
||||
is(notif.message, "Would you like to update this password?", "Check msg");
|
||||
|
||||
|
@ -573,12 +575,12 @@ add_task(async function test_changePLoginOnPForm() {
|
|||
add_task(async function test_checkUPSaveText() {
|
||||
info("Check text on a user+pass notification popup");
|
||||
|
||||
await testSubmittingLoginForm("subtst_notifications_1.html", function(
|
||||
await testSubmittingLoginForm("subtst_notifications_1.html", async function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
// Check the text, which comes from the localized saveLoginMsg string.
|
||||
let notificationText = notif.message;
|
||||
|
@ -587,7 +589,7 @@ add_task(async function test_checkUPSaveText() {
|
|||
BRAND_SHORT_NAME +
|
||||
" to save this login for example.com?";
|
||||
is(expectedText, notificationText, "Checking text: " + notificationText);
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
|
||||
is(
|
||||
|
@ -600,12 +602,12 @@ add_task(async function test_checkUPSaveText() {
|
|||
add_task(async function test_checkPSaveText() {
|
||||
info("Check text on a pass-only notification popup");
|
||||
|
||||
await testSubmittingLoginForm("subtst_notifications_6.html", function(
|
||||
await testSubmittingLoginForm("subtst_notifications_6.html", async function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "null", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
// Check the text, which comes from the localized saveLoginMsgNoUser string.
|
||||
let notificationText = notif.message;
|
||||
|
@ -614,7 +616,7 @@ add_task(async function test_checkPSaveText() {
|
|||
BRAND_SHORT_NAME +
|
||||
" to save this password for example.com?";
|
||||
is(expectedText, notificationText, "Checking text: " + notificationText);
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
|
||||
is(
|
||||
|
@ -630,15 +632,16 @@ add_task(async function test_capture2pw0un() {
|
|||
"is submitted and there are no saved logins."
|
||||
);
|
||||
|
||||
await testSubmittingLoginForm("subtst_notifications_2pw_0un.html", function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "null", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
notif.remove();
|
||||
});
|
||||
await testSubmittingLoginForm(
|
||||
"subtst_notifications_2pw_0un.html",
|
||||
async function(fieldValues) {
|
||||
is(fieldValues.username, "null", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
);
|
||||
|
||||
is(
|
||||
Services.logins.getAllLogins().length,
|
||||
|
@ -655,15 +658,16 @@ add_task(async function test_change2pw0unExistingDifferentUP() {
|
|||
|
||||
Services.logins.addLogin(login1B);
|
||||
|
||||
await testSubmittingLoginForm("subtst_notifications_2pw_0un.html", function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "null", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
ok(notif, "got notification popup");
|
||||
notif.remove();
|
||||
});
|
||||
await testSubmittingLoginForm(
|
||||
"subtst_notifications_2pw_0un.html",
|
||||
async function(fieldValues) {
|
||||
is(fieldValues.username, "null", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "got notification popup");
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
);
|
||||
|
||||
let logins = Services.logins.getAllLogins();
|
||||
is(logins.length, 1, "Should only have 1 login");
|
||||
|
@ -683,15 +687,16 @@ add_task(async function test_change2pw0unExistingDifferentP() {
|
|||
|
||||
Services.logins.addLogin(login2B);
|
||||
|
||||
await testSubmittingLoginForm("subtst_notifications_2pw_0un.html", function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "null", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
ok(notif, "got notification popup");
|
||||
notif.remove();
|
||||
});
|
||||
await testSubmittingLoginForm(
|
||||
"subtst_notifications_2pw_0un.html",
|
||||
async function(fieldValues) {
|
||||
is(fieldValues.username, "null", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "got notification popup");
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
);
|
||||
|
||||
let logins = Services.logins.getAllLogins();
|
||||
is(logins.length, 1, "Should only have 1 login");
|
||||
|
@ -741,7 +746,7 @@ add_task(async function test_changeUPLoginOnPUpdateForm() {
|
|||
async function(fieldValues) {
|
||||
is(fieldValues.username, "null", "Checking submitted username");
|
||||
is(fieldValues.password, "pass2", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "got notification popup");
|
||||
|
||||
await checkDoorhangerUsernamePassword("notifyu1", "pass2");
|
||||
|
@ -776,7 +781,7 @@ add_task(async function test_recipeCaptureFields_NewLogin() {
|
|||
async function(fieldValues) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
|
||||
// Sanity check, no logins should exist yet.
|
||||
|
@ -832,7 +837,7 @@ add_task(async function test_noShowPasswordOnDismissal() {
|
|||
fieldValues
|
||||
) {
|
||||
info("Opening popup");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
let { panel } = PopupNotifications;
|
||||
|
||||
info("Hiding popup.");
|
||||
|
@ -853,6 +858,7 @@ add_task(async function test_noShowPasswordOnDismissal() {
|
|||
true,
|
||||
"Check that the Show Password field is Hidden"
|
||||
);
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -863,7 +869,7 @@ add_task(async function test_showPasswordOn1stOpenOfDismissedByDefault() {
|
|||
fieldValues
|
||||
) {
|
||||
info("Opening popup");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
let { panel } = PopupNotifications;
|
||||
|
||||
info("Hiding popup.");
|
||||
|
@ -884,6 +890,7 @@ add_task(async function test_showPasswordOn1stOpenOfDismissedByDefault() {
|
|||
true,
|
||||
"Check that the Show Password field is Hidden"
|
||||
);
|
||||
await cleanupDoorhanger(notif);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ add_task(async function test_httpsUpgradeCaptureFields_changePW() {
|
|||
async function(fieldValues) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "pass2", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "checking for a change popup");
|
||||
|
||||
await checkDoorhangerUsernamePassword("notifyu1", "pass2");
|
||||
|
@ -115,7 +115,7 @@ add_task(
|
|||
async function(fieldValues) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "pass2", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-change");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(notif, "checking for a change popup");
|
||||
|
||||
await checkDoorhangerUsernamePassword("notifyu1", "pass2");
|
||||
|
@ -178,7 +178,7 @@ add_task(async function test_httpsUpgradeCaptureFields_captureMatchingHTTP() {
|
|||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
|
||||
is(
|
||||
|
|
|
@ -71,7 +71,7 @@ add_task(async function test_saveChromeHiddenAutoClose() {
|
|||
info("waiting for popupshown");
|
||||
await notifShownPromise;
|
||||
// the popup closes and the doorhanger should appear in the opener
|
||||
let popup = getCaptureDoorhanger("password-save");
|
||||
let popup = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(popup, "got notification popup");
|
||||
await checkDoorhangerUsernamePassword("notifyu1", "notifyp1");
|
||||
// Sanity check, no logins should exist yet.
|
||||
|
@ -99,7 +99,7 @@ add_task(async function test_changeChromeHiddenAutoClose() {
|
|||
await withTestTabUntilStorageChange(url, async function() {
|
||||
info("waiting for popupshown");
|
||||
await notifShownPromise;
|
||||
let popup = getCaptureDoorhanger("password-change");
|
||||
let popup = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(popup, "got notification popup");
|
||||
await checkDoorhangerUsernamePassword("notifyu1", "pass2");
|
||||
clickDoorhangerButton(popup, CHANGE_BUTTON);
|
||||
|
@ -133,7 +133,7 @@ add_task(async function test_saveChromeVisibleSameWindow() {
|
|||
);
|
||||
await withTestTabUntilStorageChange(url, async function() {
|
||||
await notifShownPromise;
|
||||
let popup = getCaptureDoorhanger("password-save");
|
||||
let popup = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(popup, "got notification popup");
|
||||
await checkDoorhangerUsernamePassword("notifyu2", "notifyp2");
|
||||
clickDoorhangerButton(popup, REMEMBER_BUTTON);
|
||||
|
@ -157,7 +157,7 @@ add_task(async function test_changeChromeVisibleSameWindow() {
|
|||
);
|
||||
await withTestTabUntilStorageChange(url, async function() {
|
||||
await notifShownPromise;
|
||||
let popup = getCaptureDoorhanger("password-change");
|
||||
let popup = await getCaptureDoorhangerThatMayOpen("password-change");
|
||||
ok(popup, "got notification popup");
|
||||
await checkDoorhangerUsernamePassword("notifyu2", "pass2");
|
||||
clickDoorhangerButton(popup, CHANGE_BUTTON);
|
||||
|
|
|
@ -47,6 +47,7 @@ add_task(async function test_doorhanger_dismissal_un() {
|
|||
let notif = getCaptureDoorhanger("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
ok(notif.dismissed, "notification popup was automatically dismissed");
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -82,6 +83,7 @@ add_task(async function test_doorhanger_dismissal_pw() {
|
|||
let notif = getCaptureDoorhanger("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
ok(notif.dismissed, "notification popup was automatically dismissed");
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -107,12 +109,13 @@ add_task(async function test_doorhanger_shown_on_un_with_invalid_ccnumber() {
|
|||
});
|
||||
await processedPromise;
|
||||
|
||||
let notif = getCaptureDoorhanger("password-save");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
ok(
|
||||
!notif.dismissed,
|
||||
"notification popup was not automatically dismissed"
|
||||
);
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -153,6 +156,7 @@ add_task(async function test_doorhanger_dismissal_on_change() {
|
|||
let notif = getCaptureDoorhanger("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
ok(notif.dismissed, "notification popup was automatically dismissed");
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -245,7 +245,7 @@ async function openAndVerifyDoorhanger(browser, type, expected) {
|
|||
return notif;
|
||||
}
|
||||
|
||||
async function hideDoorhangerPopup(browser) {
|
||||
async function hideDoorhangerPopup() {
|
||||
info("hideDoorhangerPopup");
|
||||
if (!PopupNotifications.isPanelOpen) {
|
||||
return;
|
||||
|
@ -273,33 +273,6 @@ async function submitForm(browser) {
|
|||
});
|
||||
}
|
||||
|
||||
function verifyLogins(expectedValues) {
|
||||
let allLogins = Services.logins.getAllLogins();
|
||||
is(allLogins.length, expectedValues.count, "Check saved logins count");
|
||||
for (let i = 0; i < expectedValues.loginProperties.length; i++) {
|
||||
let expected = expectedValues[i];
|
||||
if (expected) {
|
||||
let login = allLogins[i];
|
||||
if (expected.hasOwnProperty("timesUsed")) {
|
||||
is(login.timesUsed, expected.timesUsed, "Check timesUsed");
|
||||
}
|
||||
if (expected.hasOwnProperty("passwordLength")) {
|
||||
is(
|
||||
login.password.length,
|
||||
expected.passwordLength,
|
||||
"Check passwordLength"
|
||||
);
|
||||
}
|
||||
if (expected.hasOwnProperty("username")) {
|
||||
is(login.username, expected.username, "Check username");
|
||||
}
|
||||
if (expected.hasOwnProperty("usedSince")) {
|
||||
ok(login.timeLastUsed > expected.usedSince, "Check timeLastUsed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
|
@ -359,7 +332,7 @@ add_task(async function autocomplete_generated_password_auto_saved() {
|
|||
!notif.anchorElement.hasAttribute("extraAttr"),
|
||||
"Check if the extraAttr attribute was removed"
|
||||
);
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
|
||||
storageChangedPromise = TestUtils.topicObserved(
|
||||
"passwordmgr-storage-changed",
|
||||
|
@ -369,16 +342,12 @@ add_task(async function autocomplete_generated_password_auto_saved() {
|
|||
info("waiting for submitForm");
|
||||
await submitForm(browser);
|
||||
await storageChangedPromise;
|
||||
verifyLogins({
|
||||
count: 1,
|
||||
loginProperties: [
|
||||
{
|
||||
timesUsed: autoSavedLogin.timesUsed + 1,
|
||||
username: "",
|
||||
},
|
||||
],
|
||||
});
|
||||
await hideDoorhangerPopup(browser); // make sure the popup is closed for next test
|
||||
verifyLogins([
|
||||
{
|
||||
timesUsed: autoSavedLogin.timesUsed + 1,
|
||||
username: "",
|
||||
},
|
||||
]);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -412,7 +381,7 @@ add_task(async function autocomplete_generated_password_saved_empty_username() {
|
|||
usernameValue: "",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
});
|
||||
await hideDoorhangerPopup(browser);
|
||||
await hideDoorhangerPopup();
|
||||
info("Waiting to verifyGeneratedPasswordWasFilled");
|
||||
await verifyGeneratedPasswordWasFilled(browser, passwordInputSelector);
|
||||
|
||||
|
@ -428,17 +397,13 @@ add_task(async function autocomplete_generated_password_saved_empty_username() {
|
|||
await clickDoorhangerButton(notif, CHANGE_BUTTON);
|
||||
info("Waiting for modifyLogin");
|
||||
await storageChangedPromise;
|
||||
verifyLogins({
|
||||
count: 1,
|
||||
loginProperties: [
|
||||
{
|
||||
timesUsed: savedLogin.timesUsed + 1,
|
||||
username: "",
|
||||
},
|
||||
],
|
||||
});
|
||||
await hideDoorhangerPopup(browser); // make sure the popup is closed for next test
|
||||
notif && notif.remove();
|
||||
verifyLogins([
|
||||
{
|
||||
timesUsed: savedLogin.timesUsed + 1,
|
||||
username: "",
|
||||
},
|
||||
]);
|
||||
await cleanupDoorhanger(notif); // cleanup the doorhanger for next test
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -476,7 +441,7 @@ add_task(async function ac_gen_pw_saved_empty_un_stored_non_empty_un_in_form() {
|
|||
usernameValue: "myusername",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
});
|
||||
await hideDoorhangerPopup(browser);
|
||||
await hideDoorhangerPopup();
|
||||
info("Waiting to verifyGeneratedPasswordWasFilled");
|
||||
await verifyGeneratedPasswordWasFilled(browser, passwordInputSelector);
|
||||
|
||||
|
@ -492,22 +457,18 @@ add_task(async function ac_gen_pw_saved_empty_un_stored_non_empty_un_in_form() {
|
|||
await clickDoorhangerButton(notif, REMEMBER_BUTTON);
|
||||
info("Waiting for addLogin");
|
||||
await storageChangedPromise;
|
||||
verifyLogins({
|
||||
count: 2,
|
||||
loginProperties: [
|
||||
{
|
||||
timesUsed: savedLogin.timesUsed,
|
||||
username: "",
|
||||
password: "xyzpassword",
|
||||
},
|
||||
{
|
||||
timesUsed: 1,
|
||||
username: "myusername",
|
||||
},
|
||||
],
|
||||
});
|
||||
await hideDoorhangerPopup(browser); // make sure the popup is closed for next test
|
||||
notif && notif.remove();
|
||||
verifyLogins([
|
||||
{
|
||||
timesUsed: savedLogin.timesUsed,
|
||||
username: "",
|
||||
password: "xyzpassword",
|
||||
},
|
||||
{
|
||||
timesUsed: 1,
|
||||
username: "myusername",
|
||||
},
|
||||
]);
|
||||
await cleanupDoorhanger(notif); // cleanup the doorhanger for next test
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -544,7 +505,7 @@ add_task(async function contextfill_generated_password_saved_empty_username() {
|
|||
usernameValue: "",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
});
|
||||
await hideDoorhangerPopup(browser);
|
||||
await hideDoorhangerPopup();
|
||||
info("Waiting to verifyGeneratedPasswordWasFilled");
|
||||
await verifyGeneratedPasswordWasFilled(browser, passwordInputSelector);
|
||||
|
||||
|
@ -560,17 +521,13 @@ add_task(async function contextfill_generated_password_saved_empty_username() {
|
|||
await clickDoorhangerButton(notif, CHANGE_BUTTON);
|
||||
info("Waiting for modifyLogin");
|
||||
await storageChangedPromise;
|
||||
verifyLogins({
|
||||
count: 1,
|
||||
loginProperties: [
|
||||
{
|
||||
timesUsed: savedLogin.timesUsed + 1,
|
||||
username: "",
|
||||
},
|
||||
],
|
||||
});
|
||||
await hideDoorhangerPopup(browser); // make sure the popup is closed for next test
|
||||
notif && notif.remove();
|
||||
verifyLogins([
|
||||
{
|
||||
timesUsed: savedLogin.timesUsed + 1,
|
||||
username: "",
|
||||
},
|
||||
]);
|
||||
await cleanupDoorhanger(notif); // cleanup the doorhanger for next test
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -623,16 +580,13 @@ add_task(async function autocomplete_generated_password_edited_no_auto_save() {
|
|||
});
|
||||
await clickDoorhangerButton(notif, DONT_CHANGE_BUTTON);
|
||||
|
||||
verifyLogins({
|
||||
count: 1,
|
||||
loginProperties: [
|
||||
{
|
||||
timesUsed: savedLogin.timesUsed,
|
||||
username: "",
|
||||
password: "xyzpassword",
|
||||
},
|
||||
],
|
||||
});
|
||||
verifyLogins([
|
||||
{
|
||||
timesUsed: savedLogin.timesUsed,
|
||||
username: "",
|
||||
password: "xyzpassword",
|
||||
},
|
||||
]);
|
||||
|
||||
info("waiting for submitForm");
|
||||
await submitForm(browser);
|
||||
|
@ -646,17 +600,13 @@ add_task(async function autocomplete_generated_password_edited_no_auto_save() {
|
|||
await clickDoorhangerButton(notif, CHANGE_BUTTON);
|
||||
info("Waiting for modifyLogin");
|
||||
await storageChangedPromise;
|
||||
verifyLogins({
|
||||
count: 1,
|
||||
loginProperties: [
|
||||
{
|
||||
timesUsed: savedLogin.timesUsed + 1,
|
||||
username: "",
|
||||
},
|
||||
],
|
||||
});
|
||||
await hideDoorhangerPopup(browser); // make sure the popup is closed for next test
|
||||
notif && notif.remove();
|
||||
verifyLogins([
|
||||
{
|
||||
timesUsed: savedLogin.timesUsed + 1,
|
||||
username: "",
|
||||
},
|
||||
]);
|
||||
await cleanupDoorhanger(notif); // cleanup the doorhanger for next test
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -718,17 +668,14 @@ add_task(async function contextmenu_fill_generated_password_and_set_username() {
|
|||
info("waiting for addLogin");
|
||||
await storageChangedPromise;
|
||||
// Check properties of the newly auto-saved login
|
||||
verifyLogins({
|
||||
count: 2,
|
||||
loginProperties: [
|
||||
null, // ignore the first one
|
||||
{
|
||||
timesUsed: 1,
|
||||
username: "",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
},
|
||||
],
|
||||
});
|
||||
verifyLogins([
|
||||
null, // ignore the first one
|
||||
{
|
||||
timesUsed: 1,
|
||||
username: "",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
},
|
||||
]);
|
||||
|
||||
info("Waiting to openAndVerifyDoorhanger");
|
||||
await openAndVerifyDoorhanger(browser, "password-change", {
|
||||
|
@ -737,7 +684,7 @@ add_task(async function contextmenu_fill_generated_password_and_set_username() {
|
|||
usernameValue: "differentuser",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
});
|
||||
await hideDoorhangerPopup(browser);
|
||||
await hideDoorhangerPopup();
|
||||
info("Waiting to verifyGeneratedPasswordWasFilled");
|
||||
await verifyGeneratedPasswordWasFilled(browser, passwordInputSelector);
|
||||
|
||||
|
@ -757,19 +704,15 @@ add_task(async function contextmenu_fill_generated_password_and_set_username() {
|
|||
await clickDoorhangerButton(notif, CHANGE_BUTTON);
|
||||
info("Waiting for modifyLogin");
|
||||
await storageChangedPromise;
|
||||
verifyLogins({
|
||||
count: 2,
|
||||
loginProperties: [
|
||||
null,
|
||||
{
|
||||
username: "differentuser",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
timesUsed: 1,
|
||||
},
|
||||
],
|
||||
});
|
||||
await hideDoorhangerPopup(browser); // make sure the popup is closed for next test
|
||||
notif && notif.remove();
|
||||
verifyLogins([
|
||||
null,
|
||||
{
|
||||
username: "differentuser",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
timesUsed: 2,
|
||||
},
|
||||
]);
|
||||
await cleanupDoorhanger(notif); // cleanup the doorhanger for next test
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -818,18 +761,15 @@ add_task(async function contextmenu_password_change_form_without_username() {
|
|||
info("waiting for addLogin");
|
||||
await storageChangedPromise;
|
||||
// Check properties of the newly auto-saved login
|
||||
verifyLogins({
|
||||
count: 3,
|
||||
loginProperties: [
|
||||
null, // ignore the first one
|
||||
null, // ignore the 2nd one
|
||||
{
|
||||
timesUsed: 1,
|
||||
username: "",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
},
|
||||
],
|
||||
});
|
||||
verifyLogins([
|
||||
null, // ignore the first one
|
||||
null, // ignore the 2nd one
|
||||
{
|
||||
timesUsed: 1,
|
||||
username: "",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
},
|
||||
]);
|
||||
|
||||
info("Waiting to openAndVerifyDoorhanger");
|
||||
let notif = await openAndVerifyDoorhanger(browser, "password-change", {
|
||||
|
@ -838,9 +778,8 @@ add_task(async function contextmenu_password_change_form_without_username() {
|
|||
usernameValue: "",
|
||||
passwordLength: LoginTestUtils.generation.LENGTH,
|
||||
});
|
||||
await hideDoorhangerPopup(browser);
|
||||
// remove notification so we can unambiguously check no new notification gets created later
|
||||
notif && notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
|
||||
info("Waiting to verifyGeneratedPasswordWasFilled");
|
||||
await verifyGeneratedPasswordWasFilled(browser, passwordInputSelector);
|
||||
|
@ -856,20 +795,18 @@ add_task(async function contextmenu_password_change_form_without_username() {
|
|||
|
||||
info("Waiting for modifyLogin");
|
||||
await storageChangedPromise;
|
||||
verifyLogins({
|
||||
count: 3,
|
||||
loginProperties: [
|
||||
null, // ignore the first one
|
||||
null, // ignore the 2nd one
|
||||
{
|
||||
timesUsed: 2,
|
||||
usedSince: timeLastUsed,
|
||||
},
|
||||
],
|
||||
});
|
||||
verifyLogins([
|
||||
null, // ignore the first one
|
||||
null, // ignore the 2nd one
|
||||
{
|
||||
timesUsed: 2,
|
||||
usedSince: timeLastUsed,
|
||||
},
|
||||
]);
|
||||
// Check no new doorhanger was shown
|
||||
notif = getCaptureDoorhanger("password-change");
|
||||
ok(!notif, "No new doorhanger should be shown");
|
||||
await cleanupDoorhanger(); // cleanup for next test
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -188,7 +188,7 @@ add_task(async function test_normal_popup_notification_1() {
|
|||
() => !notif.dismissed,
|
||||
"notification should not be dismissed"
|
||||
);
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -259,7 +259,7 @@ add_task(async function test_private_popup_notification_2() {
|
|||
|
||||
ok(toggleCheckbox.hidden, "Toggle should be hidden upon 2nd opening");
|
||||
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -307,7 +307,7 @@ add_task(async function test_private_popup_notification_no_capture_pref_2b() {
|
|||
|
||||
ok(!notif, "Expected no notification popup");
|
||||
if (notif) {
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -349,7 +349,7 @@ add_task(async function test_normal_popup_notification_3() {
|
|||
);
|
||||
ok(!notif, "got no notification popup");
|
||||
if (notif) {
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -400,7 +400,7 @@ add_task(async function test_private_popup_notification_3b() {
|
|||
);
|
||||
ok(!notif, "got no notification popup");
|
||||
if (notif) {
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -453,7 +453,7 @@ add_task(async function test_normal_new_password_4() {
|
|||
() => !notif.dismissed,
|
||||
"notification should not be dismissed"
|
||||
);
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -515,7 +515,7 @@ add_task(async function test_private_new_password_5() {
|
|||
() => !notif.dismissed,
|
||||
"notification should not be dismissed"
|
||||
);
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -563,7 +563,7 @@ add_task(async function test_normal_with_login_6() {
|
|||
() => !notif.dismissed,
|
||||
"notification should not be dismissed"
|
||||
);
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
Services.logins.removeLogin(login);
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ add_task(async function test_normal_http_basic_auth() {
|
|||
() => !notif.dismissed,
|
||||
"notification should not be dismissed"
|
||||
);
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -774,7 +774,7 @@ add_task(async function test_private_http_basic_auth() {
|
|||
() => notif.dismissed,
|
||||
"notification should be dismissed"
|
||||
);
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -820,7 +820,7 @@ add_task(async function test_private_http_basic_auth_no_capture_pref() {
|
|||
|
||||
ok(!notif, "got no notification popup");
|
||||
if (notif) {
|
||||
notif.remove();
|
||||
await cleanupDoorhanger(notif);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -30,6 +30,58 @@ registerCleanupFunction(
|
|||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Compared logins in storage to expected values
|
||||
*
|
||||
* @param {array} expectedLogins
|
||||
* An array of expected login properties
|
||||
*/
|
||||
function verifyLogins(expectedLogins = []) {
|
||||
let allLogins = Services.logins.getAllLogins();
|
||||
is(
|
||||
allLogins.length,
|
||||
expectedLogins.length,
|
||||
"Check actual number of logins matches the number of provided expected property-sets"
|
||||
);
|
||||
for (let i = 0; i < expectedLogins.length; i++) {
|
||||
// if the test doesn't care about comparing properties for this login, just pass false/null.
|
||||
let expected = expectedLogins[i];
|
||||
if (expected) {
|
||||
let login = allLogins[i];
|
||||
if (typeof expected.timesUsed !== "undefined") {
|
||||
is(login.timesUsed, expected.timesUsed, "Check timesUsed");
|
||||
}
|
||||
if (typeof expected.passwordLength !== "undefined") {
|
||||
is(
|
||||
login.password.length,
|
||||
expected.passwordLength,
|
||||
"Check passwordLength"
|
||||
);
|
||||
}
|
||||
if (typeof expected.username !== "undefined") {
|
||||
is(login.username, expected.username, "Check username");
|
||||
}
|
||||
if (typeof expected.password !== "undefined") {
|
||||
info(
|
||||
`verifyLogins, login has password: ${login.password}, expects: ${
|
||||
expected.password
|
||||
}`
|
||||
);
|
||||
is(login.password, expected.password, "Check password");
|
||||
}
|
||||
if (typeof expected.usedSince !== "undefined") {
|
||||
ok(login.timeLastUsed > expected.usedSince, "Check timeLastUsed");
|
||||
}
|
||||
if (typeof expected.passwordChangedSince !== "undefined") {
|
||||
ok(
|
||||
login.timePasswordChanged > expected.passwordChangedSince,
|
||||
"Check timePasswordChanged"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a test page in `DIRECTORY_URL` which automatically submits to formsubmit.sjs and returns a
|
||||
* promise resolving with the field values when the optional `aTaskFn` is done.
|
||||
|
@ -155,6 +207,23 @@ function getCaptureDoorhanger(
|
|||
return notification;
|
||||
}
|
||||
|
||||
async function getCaptureDoorhangerThatMayOpen(
|
||||
aKind,
|
||||
popupNotifications = PopupNotifications,
|
||||
browser = null
|
||||
) {
|
||||
let notif = getCaptureDoorhanger(aKind, popupNotifications, browser);
|
||||
if (notif && !notif.dismissed) {
|
||||
if (popupNotifications.panel.state !== "open") {
|
||||
await BrowserTestUtils.waitForEvent(
|
||||
popupNotifications.panel,
|
||||
"popupshown"
|
||||
);
|
||||
}
|
||||
}
|
||||
return notif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks the specified popup notification button.
|
||||
*
|
||||
|
@ -184,6 +253,18 @@ function clickDoorhangerButton(aPopup, aButtonIndex) {
|
|||
}
|
||||
}
|
||||
|
||||
async function cleanupDoorhanger(notif) {
|
||||
let PN = notif ? notif.owner : PopupNotifications;
|
||||
if (notif) {
|
||||
notif.remove();
|
||||
}
|
||||
let promiseHidden = PN.isPanelOpen
|
||||
? BrowserTestUtils.waitForEvent(PN.panel, "popuphidden")
|
||||
: Promise.resolve;
|
||||
PN.panel.hidePopup();
|
||||
await promiseHidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the doorhanger's username and password.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче