Bug 407567 - Can't add login with empty formSubmitURL and null httpRealm. r=gavin, a1.9=damons

This commit is contained in:
dolske@mozilla.com 2008-05-02 00:54:54 -07:00
parent 93d80e8ee1
commit 0c16b2e102
2 changed files with 15 additions and 4 deletions

View File

@ -363,8 +363,19 @@ LoginManager.prototype = {
if (login.password == null || login.password.length == 0)
throw "Can't add a login with a null or empty password.";
if (!login.httpRealm && !login.formSubmitURL)
if (login.formSubmitURL || login.formSubmitURL == "") {
// We have a form submit URL. Can't have a HTTP realm.
if (login.httpRealm != null)
throw "Can't add a login with both a httpRealm and formSubmitURL.";
} else if (login.httpRealm) {
// We have a HTTP realm. Can't have a form submit URL.
if (login.formSubmitURL != null)
throw "Can't add a login with both a httpRealm and formSubmitURL.";
} else {
// Need one or the other!
throw "Can't add a login without a httpRealm or formSubmitURL.";
}
// Look for an existing entry.
var logins = this.findLogins({}, login.hostname, login.formSubmitURL,

View File

@ -81,15 +81,15 @@ const LoginTest = {
checkExpectedError : function (aExpectedError, aActualError) {
if (aExpectedError) {
if (!aActualError)
throw "Storage didn't throw as expected (" + aExpectedError + ")";
throw "Test didn't throw as expected (" + aExpectedError + ")";
if (!aExpectedError.test(aActualError))
throw "Storage threw (" + aActualError + "), not (" + aExpectedError;
throw "Test threw (" + aActualError + "), not (" + aExpectedError;
// We got the expected error, so make a note in the test log.
dump("...that error was expected.\n\n");
} else if (aActualError) {
throw "Component threw unexpected error: " + aActualError;
throw "Test threw unexpected error: " + aActualError;
}
},