Bug 1243729 - Part I, Add assertions on saved password data, r=MattN

MozReview-Commit-ID: At6U5Rgi9zD
This commit is contained in:
Timothy Guan-tin Chien 2016-04-06 14:22:39 +08:00
Родитель 52394430f4
Коммит 44246c4b68
2 изменённых файлов: 129 добавлений и 4 удалений

Просмотреть файл

@ -51,6 +51,8 @@ add_task(function* test_clickNever() {
clickDoorhangerButton(notif, NEVER_BUTTON);
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
info("Make sure Never took effect");
yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
is(fieldValues.username, "notifyu1", "Checking submitted username");
@ -61,6 +63,8 @@ add_task(function* test_clickNever() {
"Checking for login saving disabled");
Services.logins.setLoginSavingEnabled("http://mochi.test:8888", true);
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
});
add_task(function* test_clickRemember() {
@ -74,6 +78,13 @@ add_task(function* test_clickRemember() {
clickDoorhangerButton(notif, REMEMBER_BUTTON);
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu1", "Check the username used on the new entry");
is(login.password, "notifyp1", "Check the password used on the new entry");
is(login.timesUsed, 1, "Check times used on new entry");
info("Make sure Remember took effect and we don't prompt for an existing login");
yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
is(fieldValues.username, "notifyu1", "Checking submitted username");
@ -82,6 +93,13 @@ add_task(function* test_clickRemember() {
ok(!notif, "checking for no notification popup");
});
logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu1", "Check the username used");
is(login.password, "notifyp1", "Check the password used");
is(login.timesUsed, 2, "Check times used incremented");
checkOnlyLoginWasUsedTwice({ justChanged: false });
// remove that login
@ -100,6 +118,8 @@ add_task(function* test_rememberSignonsFalse() {
let notif = getCaptureDoorhanger("password-save");
ok(!notif, "checking for no notification popup");
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
});
add_task(function* test_rememberSignonsTrue() {
@ -113,6 +133,8 @@ add_task(function* test_rememberSignonsTrue() {
ok(notif, "got notification popup");
notif.remove();
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
});
/* autocomplete=off tests... */
@ -127,6 +149,8 @@ add_task(function* test_autocompleteOffUsername() {
ok(notif, "checking for notification popup");
notif.remove();
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
});
add_task(function* test_autocompleteOffPassword() {
@ -139,6 +163,8 @@ add_task(function* test_autocompleteOffPassword() {
ok(notif, "checking for notification popup");
notif.remove();
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
});
add_task(function* test_autocompleteOffForm() {
@ -151,6 +177,8 @@ add_task(function* test_autocompleteOffForm() {
ok(notif, "checking for notification popup");
notif.remove();
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
});
@ -163,6 +191,8 @@ add_task(function* test_noPasswordField() {
let notif = getCaptureDoorhanger("password-save");
ok(!notif, "checking for no notification popup");
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
});
add_task(function* test_pwOnlyLoginMatchesForm() {
@ -177,6 +207,13 @@ add_task(function* test_pwOnlyLoginMatchesForm() {
notif.remove();
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "", "Check the username");
is(login.password, "notifyp1", "Check the password");
is(login.timesUsed, 1, "Check times used");
Services.logins.removeLogin(login2);
});
@ -191,6 +228,13 @@ add_task(function* test_pwOnlyFormMatchesLogin() {
ok(!notif, "checking for no notification popup");
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu1", "Check the username");
is(login.password, "notifyp1", "Check the password");
is(login.timesUsed, 2, "Check times used");
Services.logins.removeLogin(login1);
});
@ -206,6 +250,13 @@ add_task(function* test_pwOnlyFormDoesntMatchExisting() {
notif.remove();
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu1B", "Check the username unchanged");
is(login.password, "notifyp1B", "Check the password unchanged");
is(login.timesUsed, 1, "Check times used");
Services.logins.removeLogin(login1B);
});
@ -221,6 +272,13 @@ add_task(function* test_changeUPLoginOnUPForm_dont() {
clickDoorhangerButton(notif, DONT_CHANGE_BUTTON);
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu1", "Check the username unchanged");
is(login.password, "notifyp1", "Check the password unchanged");
is(login.timesUsed, 1, "Check times used");
Services.logins.removeLogin(login1);
});
@ -237,6 +295,13 @@ add_task(function* test_changeUPLoginOnUPForm_change() {
ok(!getCaptureDoorhanger("password-change"), "popup should be gone");
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu1", "Check the username unchanged");
is(login.password, "pass2", "Check the password changed");
is(login.timesUsed, 2, "Check times used");
checkOnlyLoginWasUsedTwice({ justChanged: true });
// cleanup
@ -257,6 +322,15 @@ add_task(function* test_changePLoginOnUPForm() {
clickDoorhangerButton(notif, CHANGE_BUTTON);
ok(!getCaptureDoorhanger("password-change"), "popup should be gone");
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "", "Check the username unchanged");
is(login.password, "pass2", "Check the password changed");
is(login.timesUsed, 2, "Check times used");
// no cleanup -- saved password to be used in the next test.
});
add_task(function* test_changePLoginOnPForm() {
@ -270,6 +344,14 @@ add_task(function* test_changePLoginOnPForm() {
clickDoorhangerButton(notif, CHANGE_BUTTON);
ok(!getCaptureDoorhanger("password-change"), "popup should be gone");
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "", "Check the username unchanged");
is(login.password, "notifyp1", "Check the password changed");
is(login.timesUsed, 3, "Check times used");
Services.logins.removeLogin(login2);
});
@ -287,6 +369,8 @@ add_task(function* test_checkUPSaveText() {
is(expectedText, notificationText, "Checking text: " + notificationText);
notif.remove();
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
});
add_task(function* test_checkPSaveText() {
@ -303,6 +387,8 @@ add_task(function* test_checkPSaveText() {
is(expectedText, notificationText, "Checking text: " + notificationText);
notif.remove();
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
});
add_task(function* test_capture2pw0un() {
@ -316,6 +402,8 @@ add_task(function* test_capture2pw0un() {
ok(notif, "got notification popup");
notif.remove();
});
is(Services.logins.getAllLogins().length, 0, "Should not have any logins yet");
});
add_task(function* test_change2pw0unExistingDifferentUP() {
@ -332,6 +420,13 @@ add_task(function* test_change2pw0unExistingDifferentUP() {
notif.remove();
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu1B", "Check the username unchanged");
is(login.password, "notifyp1B", "Check the password unchanged");
is(login.timesUsed, 1, "Check times used");
Services.logins.removeLogin(login1B);
});
@ -349,6 +444,13 @@ add_task(function* test_change2pw0unExistingDifferentP() {
notif.remove();
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "", "Check the username unchanged");
is(login.password, "notifyp1B", "Check the password unchanged");
is(login.timesUsed, 1, "Check times used");
Services.logins.removeLogin(login2B);
});
@ -365,6 +467,13 @@ add_task(function* test_change2pw0unExistingWithSameP() {
ok(!notif, "checking for no notification popup");
});
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "", "Check the username unchanged");
is(login.password, "notifyp1", "Check the password unchanged");
is(login.timesUsed, 2, "Check times used incremented");
checkOnlyLoginWasUsedTwice({ justChanged: false });
Services.logins.removeLogin(login2);
@ -385,6 +494,13 @@ add_task(function* test_recipeCaptureFields_NewLogin() {
clickDoorhangerButton(notif, REMEMBER_BUTTON);
}, "http://example.org"); // The recipe is for example.org
let logins = Services.logins.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu1", "Check the username unchanged");
is(login.password, "notifyp1", "Check the password unchanged");
is(login.timesUsed, 1, "Check times used");
});
add_task(function* test_recipeCaptureFields_ExistingLogin() {
@ -400,8 +516,11 @@ add_task(function* test_recipeCaptureFields_ExistingLogin() {
checkOnlyLoginWasUsedTwice({ justChanged: false });
let logins = Services.logins.getAllLogins();
is(logins[0].username, "notifyu1", "check .username for existing login submission");
is(logins[0].password, "notifyp1", "check .password for existing login submission");
is(logins.length, 1, "Should only have 1 login");
let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu1", "Check the username unchanged");
is(login.password, "notifyp1", "Check the password unchanged");
is(login.timesUsed, 2, "Check times used incremented");
Services.logins.removeAllLogins();
});

Просмотреть файл

@ -81,7 +81,9 @@ function checkTest() {
logins = pwmgr.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
ok(login.timesUsed, 1, "Check times used on new entry");
is(login.username, "notifyu1", "Check the username used on the new entry");
is(login.password, "notifyp1", "Check the password used on the new entry");
is(login.timesUsed, 1, "Check times used on new entry");
// password-change with chrome hidden
popup = getPopup(popupNotifications, "password-change");
@ -95,6 +97,7 @@ function checkTest() {
logins = pwmgr.getAllLogins();
is(logins.length, 1, "Should only have 1 login");
login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu1", "Check the username");
is(login.password, "pass2", "Check password changed");
is(login.timesUsed, 2, "check .timesUsed incremented on change");
ok(login.timeCreated < login.timeLastUsed, "timeLastUsed bumped");
@ -120,7 +123,9 @@ function checkTest() {
logins = pwmgr.getAllLogins();
is(logins.length, 1, "Should only have 1 login now");
login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
ok(login.timesUsed, 1, "Check times used on new entry");
is(login.username, "notifyu2", "Check the username used on the new entry");
is(login.password, "notifyp2", "Check the password used on the new entry");
is(login.timesUsed, 1, "Check times used on new entry");
// password-change with chrome visible
popupWin = iframe.contentWindow.popupWin;
@ -139,6 +144,7 @@ function checkTest() {
logins = pwmgr.getAllLogins();
is(logins.length, 1, "Should have 1 login");
login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
is(login.username, "notifyu2", "Check the username");
is(login.password, "pass2", "Check password changed");
is(login.timesUsed, 2, "check .timesUsed incremented on change");
ok(login.timeCreated < login.timeLastUsed, "timeLastUsed bumped");