Bug 397799 - password manager infobar doesn't disappear after clicking remember in some cases. r=gavin, a=blocking-ff3+

This commit is contained in:
dolske@mozilla.com 2008-01-14 18:50:46 -08:00
Родитель 1ff878cb95
Коммит 45ab69eead
4 изменённых файлов: 29 добавлений и 34 удалений

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

@ -37,7 +37,7 @@
#include "nsISupports.idl"
[scriptable, uuid(a437458b-baca-4a71-a839-13861a2fd538)]
[scriptable, uuid(9c87a9bd-bf8b-4fae-bdb8-70513b2877df)]
/**
* An object containing information for a login stored by the
@ -114,26 +114,26 @@ interface nsILoginInfo : nsISupports {
in AString aUsernameField, in AString aPasswordField);
/**
* Test for equality with another nsILoginInfo object.
* Test for strict equality with another nsILoginInfo object.
*
* @param aLoginInfo
* The other object to test.
*
* NOTE: The formSubmitURL field is not strictly checked. A blank (but
* not NULL) value will match any value (except null) in the other
* object's formSubmitURL field. The blank value indicates the login
* was stored before bug 360493 was fixed.
*/
boolean equals(in nsILoginInfo aLoginInfo);
/**
* Test for equality with another nsILoginInfo object, with the
* password fields ignored.
* Test for loose equivalency with another nsILoginInfo object. The
* passwordField and usernameField values are ignored, and the password
* values may be optionally ignored. If one login's formSubmitURL is an
* empty string (but not null), it will be treated as a wildcard. [The
* blank value indicates the login was stored before bug 360493 was fixed.]
*
* @param aLoginInfo
* The other object to test.
* @param ignorePassword
* If true, ignore the password when checking for match.
*/
boolean equalsIgnorePassword(in nsILoginInfo aLoginInfo);
boolean matches(in nsILoginInfo aLoginInfo, in boolean ignorePassword);
};
%{C++

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

@ -75,8 +75,13 @@ nsLoginInfo.prototype = {
this.passwordField = aPasswordField;
},
equalsIgnorePassword : function (aLogin) {
if (this.hostname != aLogin.hostname)
matches : function (aLogin, ignorePassword) {
if (this.hostname != aLogin.hostname ||
this.httpRealm != aLogin.httpRealm ||
this.username != aLogin.username)
return false;
if (!ignorePassword && this.password != aLogin.password)
return false;
// If either formSubmitURL is blank (but not null), then match.
@ -84,23 +89,18 @@ nsLoginInfo.prototype = {
this.formSubmitURL != aLogin.formSubmitURL)
return false;
if (this.httpRealm != aLogin.httpRealm)
return false;
if (this.username != aLogin.username)
return false;
if (this.usernameField != aLogin.usernameField)
return false;
// The .password and .passwordField values are ignored.
// The .usernameField and .passwordField values are ignored.
return true;
},
equals : function (aLogin) {
if (!this.equalsIgnorePassword(aLogin) ||
this.password != aLogin.password ||
if (this.hostname != aLogin.hostname ||
this.formSubmitURL != aLogin.formSubmitURL ||
this.httpRealm != aLogin.httpRealm ||
this.username != aLogin.username ||
this.password != aLogin.password ||
this.usernameField != aLogin.usernameField ||
this.passwordField != aLogin.passwordField)
return false;

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

@ -358,7 +358,7 @@ LoginManager.prototype = {
var logins = this.findLogins({}, login.hostname, login.formSubmitURL,
login.httpRealm);
if (logins.some(function(l) { return login.username == l.username }))
if (logins.some(function(l) login.matches(l, true)))
throw "This login already exists.";
this.log("Adding login: " + login);
@ -807,14 +807,14 @@ LoginManager.prototype = {
if (!login.username && formLogin.username) {
var restoreMe = formLogin.username;
formLogin.username = "";
same = formLogin.equals(login);
same = formLogin.matches(login);
formLogin.username = restoreMe;
} else if (!formLogin.username && login.username) {
formLogin.username = login.username;
same = formLogin.equals(login);
same = formLogin.matches(login);
formLogin.username = ""; // we know it's always blank.
} else {
same = formLogin.equalsIgnorePassword(login);
same = formLogin.matches(login, true);
}
if (same) {
@ -1089,7 +1089,7 @@ LoginManager.prototype = {
if (!logins.some(function(l) {
match = l;
return currentLogin.equalsIgnorePassword(l);
return currentLogin.matches(l, true);
}))
{
this.log("Can't find a login for this autocomplete result.");

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

@ -127,11 +127,6 @@ const LoginTest = {
found = false;
for (j = 0; !found && j < stor_logins.length; j++) {
found = ref_logins[i].equals(stor_logins[j]);
// Ugh. The .equals() does fuzzy matching on the formSubmitURL
// fields sometimes, since "" is a wildcard value. But we want
// strict matching in the tests, so explicitly check it here.
if (ref_logins[i].formSubmitURL != stor_logins[j].formSubmitURL)
found = false;
}
do_check_true(found);
}