Bug 435531 – problem saving login when form or existing login is password-only. r=gavin

This commit is contained in:
Justin Dolske 2008-07-13 00:04:30 -07:00
parent 27d6fa4dd2
commit 0407b8e188
4 changed files with 97 additions and 9 deletions

View File

@ -842,11 +842,11 @@ LoginManager.prototype = {
if (!login.username && formLogin.username) {
var restoreMe = formLogin.username;
formLogin.username = "";
same = formLogin.matches(login);
same = formLogin.matches(login, false);
formLogin.username = restoreMe;
} else if (!formLogin.username && login.username) {
formLogin.username = login.username;
same = formLogin.matches(login);
same = formLogin.matches(login, false);
formLogin.username = ""; // we know it's always blank.
} else {
same = formLogin.matches(login, true);

View File

@ -83,6 +83,7 @@ MOCHI_CONTENT = \
subtst_notifications_3.html \
subtst_notifications_4.html \
subtst_notifications_5.html \
subtst_notifications_6.html \
$(NULL)
XPCSHELL_TESTS = unit

View File

@ -0,0 +1,27 @@
<html>
<head>
<title>Subtest for Login Manager notifications</title>
</head>
<body>
<h2>Subtest 6</h2>
(password-only form)
<form id="form" action="formsubmit.sjs">
<input id="pass" name="pass" type="password">
<button type='submit'>Submit</button>
</form>
<script>
function submitForm() {
//userField.value = "notifyu1";
passField.value = "notifyp1";
form.submit();
}
window.onload = submitForm;
var form = document.getElementById("form");
//var userField = document.getElementById("user");
var passField = document.getElementById("pass");
</script>
</body>
</html>

View File

@ -32,7 +32,11 @@ var subtests = [
"subtst_notifications_2.html", // 9
"subtst_notifications_3.html", // 10
"subtst_notifications_4.html", // 11
"subtst_notifications_5.html"
"subtst_notifications_5.html", // 12
"subtst_notifications_1.html", // 13
"subtst_notifications_6.html", // 14
"subtst_notifications_1.html", // 15
"subtst_notifications_6.html"
];
/*
@ -199,11 +203,7 @@ function checkTest() {
bar = getNotificationBar(notifyBox, "password-save");
ok(!bar, "checking for no notification bar");
// remove that login
var login = Cc["@mozilla.org/login-manager/loginInfo;1"].
createInstance(Ci.nsILoginInfo);
login.init("http://localhost:8888", "http://localhost:8888", null,
"notifyu1", "notifyp1", "user", "pass");
pwmgr.removeLogin(login);
pwmgr.removeLogin(login1);
break;
/* signons.rememberSignons pref tests... */
@ -272,6 +272,56 @@ function checkTest() {
is(gotPass, "null", "Checking submitted password");
bar = getNotificationBar(notifyBox, "password-save");
ok(!bar, "checking for no notification bar");
// Add login for the next test.
pwmgr.addLogin(login2);
break;
case 13:
// Check for no notification bar when existing pw-only login matches form.
is(gotUser, "notifyu1", "Checking submitted username");
is(gotPass, "notifyp1", "Checking submitted password");
bar = getNotificationBar(notifyBox, "password-save");
ok(!bar, "checking for no notification bar");
pwmgr.removeLogin(login2);
// Add login for the next test
pwmgr.addLogin(login1);
break;
case 14:
// Check for no notification bar when pw-only form matches existing login.
is(gotUser, "null", "Checking submitted username");
is(gotPass, "notifyp1", "Checking submitted password");
bar = getNotificationBar(notifyBox, "password-save");
ok(!bar, "checking for no notification bar");
pwmgr.removeLogin(login1);
// Add login for the next test
pwmgr.addLogin(login2B);
break;
case 15:
// Check for notification bar when existing pw-only login doesn't match form.
is(gotUser, "notifyu1", "Checking submitted username");
is(gotPass, "notifyp1", "Checking submitted password");
bar = getNotificationBar(notifyBox, "password-save");
ok(bar, "got notification bar");
clickNotificationButton(bar, "Not Now");
pwmgr.removeLogin(login2B);
// Add login for the next test
pwmgr.addLogin(login1B);
break;
case 16:
// Check for notification bar when pw-only form doesn't match existing login.
is(gotUser, "null", "Checking submitted username");
is(gotPass, "notifyp1", "Checking submitted password");
bar = getNotificationBar(notifyBox, "password-save");
ok(bar, "got notification bar");
clickNotificationButton(bar, "Not Now");
pwmgr.removeLogin(login1B);
break;
default:
@ -280,7 +330,6 @@ function checkTest() {
}
// TODO:
// * existing login test, when only one of form/login has a username --> no prompt
// * existing login test, form has different password --> change password, no save prompt
}
@ -302,6 +351,17 @@ ok(prefs != null, "Access prefs");
prefs = prefs.getBranch("signon.");
ok(prefs != null, "Access pref branch");
var nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
Ci.nsILoginInfo, "init");
var login1 = new nsLoginInfo("http://localhost:8888", "http://localhost:8888", null,
"notifyu1", "notifyp1", "user", "pass");
var login2 = new nsLoginInfo("http://localhost:8888", "http://localhost:8888", null,
"", "notifyp1", "", "pass");
var login1B = new nsLoginInfo("http://localhost:8888", "http://localhost:8888", null,
"notifyu1B", "notifyp1B", "user", "pass");
var login2B = new nsLoginInfo("http://localhost:8888", "http://localhost:8888", null,
"", "notifyp1B", "", "pass");
var iframe = document.getElementById("iframe");
iframe.onload = handleLoad;