Bug 1569917 - Change the string on the doorhanger when adding a username to a login. r=sfoster

Make it more clear that the password isn't changing, only the username.

Differential Revision: https://phabricator.services.mozilla.com/D40222

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matthew Noorenberghe 2019-08-01 20:41:29 +00:00
parent dffcef5d18
commit 309b4c9c4b
3 changed files with 32 additions and 2 deletions

View File

@ -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,
}
);

View File

@ -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);

View File

@ -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 = Dont Update