diff --git a/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js b/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js index 9d82f85405c..b25c0eca267 100644 --- a/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js +++ b/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js @@ -835,11 +835,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); diff --git a/mozilla/toolkit/components/passwordmgr/test/Makefile.in b/mozilla/toolkit/components/passwordmgr/test/Makefile.in index 13841910af8..eacb679f42e 100644 --- a/mozilla/toolkit/components/passwordmgr/test/Makefile.in +++ b/mozilla/toolkit/components/passwordmgr/test/Makefile.in @@ -80,6 +80,7 @@ MOCHI_CONTENT = \ subtst_notifications_3.html \ subtst_notifications_4.html \ subtst_notifications_5.html \ + subtst_notifications_6.html \ $(NULL) XPCSHELL_TESTS = unit diff --git a/mozilla/toolkit/components/passwordmgr/test/subtst_notifications_6.html b/mozilla/toolkit/components/passwordmgr/test/subtst_notifications_6.html new file mode 100644 index 00000000000..c919f44992a --- /dev/null +++ b/mozilla/toolkit/components/passwordmgr/test/subtst_notifications_6.html @@ -0,0 +1,27 @@ + + + Subtest for Login Manager notifications + + +

Subtest 6

+(password-only form) +
+ + +
+ + + + diff --git a/mozilla/toolkit/components/passwordmgr/test/test_notifications.html b/mozilla/toolkit/components/passwordmgr/test/test_notifications.html index e66b19a7504..84ef756fc40 100644 --- a/mozilla/toolkit/components/passwordmgr/test/test_notifications.html +++ b/mozilla/toolkit/components/passwordmgr/test/test_notifications.html @@ -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" ]; /* @@ -186,11 +190,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... */ @@ -259,6 +259,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: @@ -267,7 +317,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 } @@ -289,6 +338,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;