mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Bug 1463797 - Added a method to hit enter to save passwords while password box is focused and test. r=MattN
Differential Revision: https://phabricator.services.mozilla.com/D43306 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
0cfc13adee
commit
ba71d5287d
@ -1030,7 +1030,6 @@ LoginManagerPrompter.prototype = {
|
||||
);
|
||||
|
||||
let chromeDoc = browser.ownerDocument;
|
||||
|
||||
let currentNotification;
|
||||
|
||||
let updateButtonStatus = element => {
|
||||
@ -1126,6 +1125,12 @@ LoginManagerPrompter.prototype = {
|
||||
updateButtonLabel();
|
||||
};
|
||||
|
||||
let onKeyUp = e => {
|
||||
if (e.key == "Enter") {
|
||||
e.target.closest("popupnotification").button.doCommand();
|
||||
}
|
||||
};
|
||||
|
||||
let onVisibilityToggle = commandEvent => {
|
||||
let passwordField = chromeDoc.getElementById(
|
||||
"password-notification-password"
|
||||
@ -1313,6 +1318,12 @@ LoginManagerPrompter.prototype = {
|
||||
chromeDoc
|
||||
.getElementById("password-notification-username")
|
||||
.addEventListener("input", onInput);
|
||||
chromeDoc
|
||||
.getElementById("password-notification-username")
|
||||
.addEventListener("keyup", onKeyUp);
|
||||
chromeDoc
|
||||
.getElementById("password-notification-password")
|
||||
.addEventListener("keyup", onKeyUp);
|
||||
chromeDoc
|
||||
.getElementById("password-notification-password")
|
||||
.addEventListener("input", onInput);
|
||||
@ -1360,9 +1371,15 @@ LoginManagerPrompter.prototype = {
|
||||
chromeDoc
|
||||
.getElementById("password-notification-username")
|
||||
.removeEventListener("input", onInput);
|
||||
chromeDoc
|
||||
.getElementById("password-notification-username")
|
||||
.removeEventListener("keyup", onKeyUp);
|
||||
chromeDoc
|
||||
.getElementById("password-notification-password")
|
||||
.removeEventListener("input", onInput);
|
||||
chromeDoc
|
||||
.getElementById("password-notification-password")
|
||||
.removeEventListener("keyup", onKeyUp);
|
||||
chromeDoc
|
||||
.getElementById("password-notification-visibilityToggle")
|
||||
.removeEventListener("command", onVisibilityToggle);
|
||||
|
@ -830,6 +830,48 @@ add_task(async function test_recipeCaptureFields_ExistingLogin() {
|
||||
Services.logins.removeAllLogins();
|
||||
});
|
||||
|
||||
add_task(async function test_saveUsingEnter() {
|
||||
async function testWithTextboxSelector(fieldSelector) {
|
||||
let storageChangedPromise = TestUtils.topicObserved(
|
||||
"passwordmgr-storage-changed",
|
||||
(_, data) => data == "addLogin"
|
||||
);
|
||||
|
||||
info("Waiting for form submit and doorhanger interaction");
|
||||
await testSubmittingLoginForm("subtst_notifications_1.html", async function(
|
||||
fieldValues
|
||||
) {
|
||||
is(fieldValues.username, "notifyu1", "Checking submitted username");
|
||||
is(fieldValues.password, "notifyp1", "Checking submitted password");
|
||||
let notif = await getCaptureDoorhangerThatMayOpen("password-save");
|
||||
ok(notif, "got notification popup");
|
||||
is(
|
||||
Services.logins.getAllLogins().length,
|
||||
0,
|
||||
"Should not have any logins yet"
|
||||
);
|
||||
await checkDoorhangerUsernamePassword("notifyu1", "notifyp1");
|
||||
let notificationElement = PopupNotifications.panel.childNodes[0];
|
||||
let textbox = notificationElement.querySelector(fieldSelector);
|
||||
textbox.focus();
|
||||
await EventUtils.synthesizeKey("KEY_Enter");
|
||||
});
|
||||
await storageChangedPromise;
|
||||
|
||||
let logins = Services.logins.getAllLogins();
|
||||
is(logins.length, 1, "Should only have 1 login");
|
||||
let login = logins[0].QueryInterface(Ci.nsILoginMetaInfo);
|
||||
is(login.username, "notifyu1", "Check the username used on the new entry");
|
||||
is(login.password, "notifyp1", "Check the password used on the new entry");
|
||||
is(login.timesUsed, 1, "Check times used on new entry");
|
||||
|
||||
Services.logins.removeAllLogins();
|
||||
}
|
||||
|
||||
await testWithTextboxSelector("#password-notification-password");
|
||||
await testWithTextboxSelector("#password-notification-username");
|
||||
});
|
||||
|
||||
add_task(async function test_noShowPasswordOnDismissal() {
|
||||
info("Check for no Show Password field when the doorhanger is dismissed");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user