зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1576271 - Logins with no username should show '(no username)' in the login-item view when not editing. r=MattN,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D43334 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a08b5323cb
Коммит
b28d468032
|
@ -128,6 +128,15 @@ export default class LoginItem extends HTMLElement {
|
|||
this._originInput.defaultValue = this._login.origin || "";
|
||||
this._usernameInput.defaultValue = this._login.username || "";
|
||||
this._passwordInput.defaultValue = this._login.password || "";
|
||||
if (this.dataset.editing) {
|
||||
this._usernameInput.removeAttribute("data-l10n-id");
|
||||
} else {
|
||||
document.l10n.setAttributes(
|
||||
this._usernameInput,
|
||||
"about-logins-login-item-username"
|
||||
);
|
||||
}
|
||||
this._copyUsernameButton.disabled = !this._login.username;
|
||||
document.l10n.setAttributes(
|
||||
this._saveChangesButton,
|
||||
this.dataset.isNewLogin
|
||||
|
@ -279,6 +288,7 @@ export default class LoginItem extends HTMLElement {
|
|||
}
|
||||
if (classList.contains("edit-button")) {
|
||||
this._toggleEditing();
|
||||
this.render();
|
||||
|
||||
recordTelemetryEvent({ object: "existing_login", method: "edit" });
|
||||
return;
|
||||
|
|
|
@ -86,7 +86,9 @@ add_task(async function test_set_login() {
|
|||
ok(!gLoginItem.dataset.isNewLogin, "loginItem should not be in 'isNewLogin' mode");
|
||||
let originInput = gLoginItem.shadowRoot.querySelector("input[name='origin']");
|
||||
is(originInput.value, TEST_LOGIN_1.origin, "origin should be populated");
|
||||
is(gLoginItem.shadowRoot.querySelector("input[name='username']").value, TEST_LOGIN_1.username, "username should be populated");
|
||||
let usernameInput = gLoginItem.shadowRoot.querySelector("input[name='username']");
|
||||
is(usernameInput.value, TEST_LOGIN_1.username, "username should be populated");
|
||||
is(document.l10n.getAttributes(usernameInput).id, "about-logins-login-item-username", "username field should have default placeholder when not editing");
|
||||
is(gLoginItem.shadowRoot.querySelector("input[name='password']").value, TEST_LOGIN_1.password, "password should be populated");
|
||||
is(document.l10n.getAttributes(gLoginItem.shadowRoot.querySelector(".time-created")).args.timeCreated, TEST_LOGIN_1.timeCreated, "time-created should be populated");
|
||||
is(document.l10n.getAttributes(gLoginItem.shadowRoot.querySelector(".time-changed")).args.timeChanged, TEST_LOGIN_1.timePasswordChanged, "time-changed should be populated");
|
||||
|
@ -114,6 +116,16 @@ add_task(async function test_set_login() {
|
|||
ok(false, "right-clicking the .origin-input should not trigger the AboutLoginsOpenSite event");
|
||||
}, {once: true});
|
||||
synthesizeMouseAtCenter(originInput, {button: 2});
|
||||
|
||||
let loginNoUsername = Object.assign({}, TEST_LOGIN_1, {username: ""});
|
||||
gLoginItem.setLogin(loginNoUsername);
|
||||
ok(!gLoginItem.dataset.editing, "loginItem should not be in 'edit' mode");
|
||||
is(document.l10n.getAttributes(usernameInput).id, "about-logins-login-item-username", "username field should have default placeholder when username is not present and not editing");
|
||||
let copyUsernameButton = gLoginItem.shadowRoot.querySelector(".copy-username-button");
|
||||
ok(copyUsernameButton.disabled, "The copy-username-button should be disabled if there is no username");
|
||||
|
||||
gLoginItem.shadowRoot.querySelector(".edit-button").click();
|
||||
is(document.l10n.getAttributes(usernameInput).id, null, "username field should have no placeholder when editing");
|
||||
});
|
||||
|
||||
add_task(async function test_update_breaches() {
|
||||
|
@ -147,7 +159,9 @@ add_task(async function test_edit_login() {
|
|||
let deleteButton = gLoginItem.shadowRoot.querySelector(".delete-button");
|
||||
ok(!deleteButton.disabled, "Delete button should be enabled when editing a login");
|
||||
is(gLoginItem.shadowRoot.querySelector("input[name='origin']").value, TEST_LOGIN_1.origin, "origin should be populated");
|
||||
is(gLoginItem.shadowRoot.querySelector("input[name='username']").value, TEST_LOGIN_1.username, "username should be populated");
|
||||
let usernameInput = gLoginItem.shadowRoot.querySelector("input[name='username']");
|
||||
is(usernameInput.value, TEST_LOGIN_1.username, "username should be populated");
|
||||
is(document.l10n.getAttributes(usernameInput).id, null, "username field should have no placeholder in edit mode");
|
||||
is(gLoginItem.shadowRoot.querySelector("input[name='password']").value, TEST_LOGIN_1.password, "password should be populated");
|
||||
is(document.l10n.getAttributes(gLoginItem.shadowRoot.querySelector(".time-created")).args.timeCreated, TEST_LOGIN_1.timeCreated, "time-created should be populated");
|
||||
is(document.l10n.getAttributes(gLoginItem.shadowRoot.querySelector(".time-changed")).args.timeChanged, TEST_LOGIN_1.timePasswordChanged, "time-changed should be populated");
|
||||
|
@ -155,7 +169,7 @@ add_task(async function test_edit_login() {
|
|||
let copyButtons = [...gLoginItem.shadowRoot.querySelectorAll(".copy-button")];
|
||||
ok(copyButtons.every(button => isHidden(button)), "The copy buttons should be hidden when editing a login");
|
||||
|
||||
gLoginItem.shadowRoot.querySelector("input[name='username']").value = "newUsername";
|
||||
usernameInput.value = "newUsername";
|
||||
gLoginItem.shadowRoot.querySelector("input[name='password']").value = "newPassword";
|
||||
|
||||
let updateEventDispatched = false;
|
||||
|
|
|
@ -83,8 +83,8 @@ login-item-origin-label = Website Address
|
|||
login-item-origin =
|
||||
.placeholder = https://www.example.com
|
||||
login-item-username-label = Username
|
||||
login-item-username =
|
||||
.placeholder = name@example.com
|
||||
about-logins-login-item-username =
|
||||
.placeholder = (no username)
|
||||
login-item-copy-username-button-text = Copy
|
||||
login-item-copied-username-button-text = Copied!
|
||||
login-item-password-label = Password
|
||||
|
|
Загрузка…
Ссылка в новой задаче