diff --git a/toolkit/components/passwordmgr/LoginManagerPrompter.jsm b/toolkit/components/passwordmgr/LoginManagerPrompter.jsm index a9ab9d5fa3df..fd06fba4199f 100644 --- a/toolkit/components/passwordmgr/LoginManagerPrompter.jsm +++ b/toolkit/components/passwordmgr/LoginManagerPrompter.jsm @@ -959,12 +959,14 @@ LoginManagerPrompter.prototype = { * Options to pass along to PopupNotifications.show(). * @param {bool} [options.notifySaved = false] * Whether to indicate to the user that the login was already saved. + * @param {string} [options.messageStringID = undefined] + * An optional string ID to override the default message. */ _showLoginCaptureDoorhanger( login, type, showOptions = {}, - { notifySaved = false } = {} + { notifySaved = false, messageStringID } = {} ) { let { browser } = this._getNotifyWindow(); if (!browser) { @@ -990,6 +992,10 @@ LoginManagerPrompter.prototype = { let initialMsgNames = type == "password-save" ? saveMsgNames : changeMsgNames; + if (messageStringID) { + changeMsgNames.prompt = messageStringID; + } + let brandBundle = Services.strings.createBundle(BRAND_BUNDLE); let brandShortName = brandBundle.GetStringFromName("brandShortName"); let host = this._getShortDisplayHost(login.origin); @@ -1452,6 +1458,19 @@ LoginManagerPrompter.prototype = { login.formActionOrigin = aNewLogin.formActionOrigin; login.password = aNewLogin.password; login.username = aNewLogin.username; + + let messageStringID; + if ( + aOldLogin.username === "" && + login.username !== "" && + login.password == aOldLogin.password + ) { + // If the saved password matches the password we're prompting with then we + // are only prompting to let the user add a username since there was one in + // the form. Change the message so the purpose of the prompt is clearer. + messageStringID = "updateLoginMsgAddUsername"; + } + this._showLoginCaptureDoorhanger( login, "password-change", @@ -1461,6 +1480,7 @@ LoginManagerPrompter.prototype = { }, { notifySaved, + messageStringID, } ); diff --git a/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js b/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js index 9aba647bcbe8..30e5214f6b09 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js +++ b/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js @@ -314,6 +314,11 @@ add_task(async function test_pwOnlyLoginMatchesForm() { is(fieldValues.password, "notifyp1", "Checking submitted password"); let notif = getCaptureDoorhanger("password-change"); ok(notif, "checking for notification popup"); + is( + notif.message, + "Would you like to add a username to the saved password?", + "Check message" + ); notif.remove(); }); @@ -389,6 +394,7 @@ add_task(async function test_changeUPLoginOnUPForm_dont() { is(fieldValues.password, "pass2", "Checking submitted password"); let notif = getCaptureDoorhanger("password-change"); ok(notif, "got notification popup"); + is(notif.message, "Would you like to update this login?", "Check message"); await checkDoorhangerUsernamePassword("notifyu1", "pass2"); clickDoorhangerButton(notif, DONT_CHANGE_BUTTON); @@ -415,6 +421,7 @@ add_task(async function test_changeUPLoginOnUPForm_change() { is(fieldValues.password, "pass2", "Checking submitted password"); let notif = getCaptureDoorhanger("password-change"); ok(notif, "got notification popup"); + is(notif.message, "Would you like to update this login?", "Check message"); await checkDoorhangerUsernamePassword("notifyu1", "pass2"); clickDoorhangerButton(notif, CHANGE_BUTTON); @@ -438,7 +445,7 @@ add_task(async function test_changeUPLoginOnUPForm_change() { }); add_task(async function test_changePLoginOnUPForm() { - info("Check for change-password popup, p-only login on u+p form."); + info("Check for change-password popup, p-only login on u+p form (empty u)."); Services.logins.addLogin(login2); await testSubmittingLoginForm("subtst_notifications_9.html", async function( @@ -448,6 +455,7 @@ add_task(async function test_changePLoginOnUPForm() { is(fieldValues.password, "pass2", "Checking submitted password"); let notif = getCaptureDoorhanger("password-change"); ok(notif, "got notification popup"); + is(notif.message, "Would you like to update this password?", "Check msg"); await checkDoorhangerUsernamePassword("", "pass2"); clickDoorhangerButton(notif, CHANGE_BUTTON); @@ -475,6 +483,7 @@ add_task(async function test_changePLoginOnPForm() { is(fieldValues.password, "notifyp1", "Checking submitted password"); let notif = getCaptureDoorhanger("password-change"); ok(notif, "got notification popup"); + is(notif.message, "Would you like to update this password?", "Check msg"); await checkDoorhangerUsernamePassword("", "notifyp1"); clickDoorhangerButton(notif, CHANGE_BUTTON); diff --git a/toolkit/locales/en-US/chrome/passwordmgr/passwordmgr.properties b/toolkit/locales/en-US/chrome/passwordmgr/passwordmgr.properties index 759cb87f75f0..83ac437a4041 100644 --- a/toolkit/locales/en-US/chrome/passwordmgr/passwordmgr.properties +++ b/toolkit/locales/en-US/chrome/passwordmgr/passwordmgr.properties @@ -17,6 +17,7 @@ saveLoginButtonNever.label = Never Save saveLoginButtonNever.accesskey = e updateLoginMsg = Would you like to update this login? updateLoginMsgNoUser = Would you like to update this password? +updateLoginMsgAddUsername = Would you like to add a username to the saved password? updateLoginButtonText = Update updateLoginButtonAccessKey = U updateLoginButtonDeny.label = Don’t Update