From 819bbcd228f3f69fa01c01919fff731a24260b8c Mon Sep 17 00:00:00 2001 From: "dolske%mozilla.com" Date: Fri, 2 May 2008 07:54:54 +0000 Subject: [PATCH] Bug 407567 - Can't add login with empty formSubmitURL and null httpRealm. r=gavin, a1.9=damons git-svn-id: svn://10.0.0.236/trunk@251086 18797224-902f-48f8-a5cc-f745e15eee43 --- .../components/passwordmgr/src/nsLoginManager.js | 13 ++++++++++++- .../passwordmgr/test/unit/head_storage_legacy_1.js | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js b/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js index e1ee54a793a..43cfd819b45 100644 --- a/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js +++ b/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js @@ -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, diff --git a/mozilla/toolkit/components/passwordmgr/test/unit/head_storage_legacy_1.js b/mozilla/toolkit/components/passwordmgr/test/unit/head_storage_legacy_1.js index c1675feba46..62f4662423d 100644 --- a/mozilla/toolkit/components/passwordmgr/test/unit/head_storage_legacy_1.js +++ b/mozilla/toolkit/components/passwordmgr/test/unit/head_storage_legacy_1.js @@ -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; } },