forked from mirrors/gecko-dev
Bug 1869544 - Use const declarations in LoginManagerPrompter.sys.mjs r=credential-management-reviewers,issammani
Differential Revision: https://phabricator.services.mozilla.com/D196178
This commit is contained in:
parent
81938d0fa0
commit
23c80b5e4c
1 changed files with 83 additions and 83 deletions
|
|
@ -57,11 +57,11 @@ const NOTIFICATION_TIMEOUT_MS = 10 * 1000; // 10 seconds
|
||||||
const ATTENTION_NOTIFICATION_TIMEOUT_MS = 60 * 1000; // 1 minute
|
const ATTENTION_NOTIFICATION_TIMEOUT_MS = 60 * 1000; // 1 minute
|
||||||
|
|
||||||
function autocompleteSelected(popup) {
|
function autocompleteSelected(popup) {
|
||||||
let doc = popup.ownerDocument;
|
const doc = popup.ownerDocument;
|
||||||
let nameField = doc.getElementById("password-notification-username");
|
const nameField = doc.getElementById("password-notification-username");
|
||||||
let passwordField = doc.getElementById("password-notification-password");
|
const passwordField = doc.getElementById("password-notification-password");
|
||||||
|
|
||||||
let activeElement = nameField.ownerDocument.activeElement;
|
const activeElement = nameField.ownerDocument.activeElement;
|
||||||
if (activeElement == nameField) {
|
if (activeElement == nameField) {
|
||||||
popup.onUsernameSelect();
|
popup.onUsernameSelect();
|
||||||
} else if (activeElement == passwordField) {
|
} else if (activeElement == passwordField) {
|
||||||
|
|
@ -76,7 +76,7 @@ const observer = {
|
||||||
observe(subject, topic, data) {
|
observe(subject, topic, data) {
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
case "autocomplete-did-enter-text": {
|
case "autocomplete-did-enter-text": {
|
||||||
let input = subject.QueryInterface(Ci.nsIAutoCompleteInput);
|
const input = subject.QueryInterface(Ci.nsIAutoCompleteInput);
|
||||||
autocompleteSelected(input.popupElement);
|
autocompleteSelected(input.popupElement);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -127,8 +127,8 @@ export class LoginManagerPrompter {
|
||||||
possibleValues = undefined
|
possibleValues = undefined
|
||||||
) {
|
) {
|
||||||
lazy.log.debug("Prompting user to save login.");
|
lazy.log.debug("Prompting user to save login.");
|
||||||
let inPrivateBrowsing = PrivateBrowsingUtils.isBrowserPrivate(aBrowser);
|
const inPrivateBrowsing = PrivateBrowsingUtils.isBrowserPrivate(aBrowser);
|
||||||
let notification = LoginManagerPrompter._showLoginCaptureDoorhanger(
|
const notification = LoginManagerPrompter._showLoginCaptureDoorhanger(
|
||||||
aBrowser,
|
aBrowser,
|
||||||
aLogin,
|
aLogin,
|
||||||
"password-save",
|
"password-save",
|
||||||
|
|
@ -146,7 +146,7 @@ export class LoginManagerPrompter {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dismiss() {
|
dismiss() {
|
||||||
let { PopupNotifications } = aBrowser.ownerGlobal.wrappedJSObject;
|
const { PopupNotifications } = aBrowser.ownerGlobal.wrappedJSObject;
|
||||||
PopupNotifications.remove(notification);
|
PopupNotifications.remove(notification);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -197,35 +197,35 @@ export class LoginManagerPrompter {
|
||||||
`Got autoSavedLoginGuid: ${autoSavedLoginGuid} and autoFilledLoginGuid ${autoFilledLoginGuid}.`
|
`Got autoSavedLoginGuid: ${autoSavedLoginGuid} and autoFilledLoginGuid ${autoFilledLoginGuid}.`
|
||||||
);
|
);
|
||||||
|
|
||||||
let saveMessageIds = {
|
const saveMessageIds = {
|
||||||
prompt: "password-manager-save-password-message",
|
prompt: "password-manager-save-password-message",
|
||||||
mainButton: "password-manager-save-password-button-allow",
|
mainButton: "password-manager-save-password-button-allow",
|
||||||
secondaryButton: "password-manager-save-password-button-deny",
|
secondaryButton: "password-manager-save-password-button-deny",
|
||||||
};
|
};
|
||||||
|
|
||||||
let changeMessageIds = {
|
const changeMessageIds = {
|
||||||
prompt: messageStringID ?? "password-manager-update-password-message",
|
prompt: messageStringID ?? "password-manager-update-password-message",
|
||||||
mainButton: "password-manager-password-password-button-allow",
|
mainButton: "password-manager-password-password-button-allow",
|
||||||
secondaryButton: "password-manager-update-password-button-deny",
|
secondaryButton: "password-manager-update-password-button-deny",
|
||||||
};
|
};
|
||||||
|
|
||||||
let initialMessageIds =
|
const initialMessageIds =
|
||||||
type == "password-save" ? saveMessageIds : changeMessageIds;
|
type == "password-save" ? saveMessageIds : changeMessageIds;
|
||||||
|
|
||||||
let promptId = initialMessageIds.prompt;
|
const promptId = initialMessageIds.prompt;
|
||||||
let host = this._getShortDisplayHost(login.origin);
|
const host = this._getShortDisplayHost(login.origin);
|
||||||
let promptMessage = lazy.l10n.formatValueSync(promptId, { host });
|
const promptMessage = lazy.l10n.formatValueSync(promptId, { host });
|
||||||
|
|
||||||
let histogramName =
|
const histogramName =
|
||||||
type == "password-save"
|
type == "password-save"
|
||||||
? "PWMGR_PROMPT_REMEMBER_ACTION"
|
? "PWMGR_PROMPT_REMEMBER_ACTION"
|
||||||
: "PWMGR_PROMPT_UPDATE_ACTION";
|
: "PWMGR_PROMPT_UPDATE_ACTION";
|
||||||
let histogram = Services.telemetry.getHistogramById(histogramName);
|
const histogram = Services.telemetry.getHistogramById(histogramName);
|
||||||
|
|
||||||
let chromeDoc = browser.ownerDocument;
|
const chromeDoc = browser.ownerDocument;
|
||||||
let currentNotification;
|
let currentNotification;
|
||||||
|
|
||||||
let wasModifiedEvent = {
|
const wasModifiedEvent = {
|
||||||
// Values are mutated
|
// Values are mutated
|
||||||
did_edit_un: "false",
|
did_edit_un: "false",
|
||||||
did_select_un: "false",
|
did_select_un: "false",
|
||||||
|
|
@ -233,8 +233,8 @@ export class LoginManagerPrompter {
|
||||||
did_select_pw: "false",
|
did_select_pw: "false",
|
||||||
};
|
};
|
||||||
|
|
||||||
let updateButtonStatus = element => {
|
const updateButtonStatus = element => {
|
||||||
let mainActionButton = element.button;
|
const mainActionButton = element.button;
|
||||||
// Disable the main button inside the menu-button if the password field is empty.
|
// Disable the main button inside the menu-button if the password field is empty.
|
||||||
if (!login.password.length) {
|
if (!login.password.length) {
|
||||||
mainActionButton.setAttribute("disabled", true);
|
mainActionButton.setAttribute("disabled", true);
|
||||||
|
|
@ -249,34 +249,34 @@ export class LoginManagerPrompter {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let updateButtonLabel = () => {
|
const updateButtonLabel = () => {
|
||||||
if (!currentNotification) {
|
if (!currentNotification) {
|
||||||
console.error("updateButtonLabel, no currentNotification");
|
console.error("updateButtonLabel, no currentNotification");
|
||||||
}
|
}
|
||||||
let foundLogins = lazy.LoginHelper.searchLoginsWithObject({
|
const foundLogins = lazy.LoginHelper.searchLoginsWithObject({
|
||||||
formActionOrigin: login.formActionOrigin,
|
formActionOrigin: login.formActionOrigin,
|
||||||
origin: login.origin,
|
origin: login.origin,
|
||||||
httpRealm: login.httpRealm,
|
httpRealm: login.httpRealm,
|
||||||
schemeUpgrades: lazy.LoginHelper.schemeUpgrades,
|
schemeUpgrades: lazy.LoginHelper.schemeUpgrades,
|
||||||
});
|
});
|
||||||
|
|
||||||
let logins = this._filterUpdatableLogins(
|
const logins = this._filterUpdatableLogins(
|
||||||
login,
|
login,
|
||||||
foundLogins,
|
foundLogins,
|
||||||
autoSavedLoginGuid
|
autoSavedLoginGuid
|
||||||
);
|
);
|
||||||
let messageIds = !logins.length ? saveMessageIds : changeMessageIds;
|
const messageIds = !logins.length ? saveMessageIds : changeMessageIds;
|
||||||
|
|
||||||
// Update the label based on whether this will be a new login or not.
|
// Update the label based on whether this will be a new login or not.
|
||||||
|
|
||||||
let mainButton = this.getLabelAndAccessKey(messageIds.mainButton);
|
const mainButton = this.getLabelAndAccessKey(messageIds.mainButton);
|
||||||
|
|
||||||
// Update the labels for the next time the panel is opened.
|
// Update the labels for the next time the panel is opened.
|
||||||
currentNotification.mainAction.label = mainButton.label;
|
currentNotification.mainAction.label = mainButton.label;
|
||||||
currentNotification.mainAction.accessKey = mainButton.accessKey;
|
currentNotification.mainAction.accessKey = mainButton.accessKey;
|
||||||
|
|
||||||
// Update the labels in real time if the notification is displayed.
|
// Update the labels in real time if the notification is displayed.
|
||||||
let element = [...currentNotification.owner.panel.childNodes].find(
|
const element = [...currentNotification.owner.panel.childNodes].find(
|
||||||
n => n.notification == currentNotification
|
n => n.notification == currentNotification
|
||||||
);
|
);
|
||||||
if (element) {
|
if (element) {
|
||||||
|
|
@ -286,19 +286,19 @@ export class LoginManagerPrompter {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let writeDataToUI = () => {
|
const writeDataToUI = () => {
|
||||||
let nameField = chromeDoc.getElementById(
|
const nameField = chromeDoc.getElementById(
|
||||||
"password-notification-username"
|
"password-notification-username"
|
||||||
);
|
);
|
||||||
|
|
||||||
nameField.placeholder = usernamePlaceholder;
|
nameField.placeholder = usernamePlaceholder;
|
||||||
nameField.value = login.username;
|
nameField.value = login.username;
|
||||||
|
|
||||||
let toggleCheckbox = chromeDoc.getElementById(
|
const toggleCheckbox = chromeDoc.getElementById(
|
||||||
"password-notification-visibilityToggle"
|
"password-notification-visibilityToggle"
|
||||||
);
|
);
|
||||||
toggleCheckbox.removeAttribute("checked");
|
toggleCheckbox.removeAttribute("checked");
|
||||||
let passwordField = chromeDoc.getElementById(
|
const passwordField = chromeDoc.getElementById(
|
||||||
"password-notification-password"
|
"password-notification-password"
|
||||||
);
|
);
|
||||||
// Ensure the type is reset so the field is masked.
|
// Ensure the type is reset so the field is masked.
|
||||||
|
|
@ -308,7 +308,7 @@ export class LoginManagerPrompter {
|
||||||
updateButtonLabel();
|
updateButtonLabel();
|
||||||
};
|
};
|
||||||
|
|
||||||
let readDataFromUI = () => {
|
const readDataFromUI = () => {
|
||||||
login.username = chromeDoc.getElementById(
|
login.username = chromeDoc.getElementById(
|
||||||
"password-notification-username"
|
"password-notification-username"
|
||||||
).value;
|
).value;
|
||||||
|
|
@ -317,46 +317,46 @@ export class LoginManagerPrompter {
|
||||||
).value;
|
).value;
|
||||||
};
|
};
|
||||||
|
|
||||||
let onInput = () => {
|
const onInput = () => {
|
||||||
readDataFromUI();
|
readDataFromUI();
|
||||||
updateButtonLabel();
|
updateButtonLabel();
|
||||||
};
|
};
|
||||||
|
|
||||||
let onUsernameInput = () => {
|
const onUsernameInput = () => {
|
||||||
wasModifiedEvent.did_edit_un = "true";
|
wasModifiedEvent.did_edit_un = "true";
|
||||||
wasModifiedEvent.did_select_un = "false";
|
wasModifiedEvent.did_select_un = "false";
|
||||||
onInput();
|
onInput();
|
||||||
};
|
};
|
||||||
|
|
||||||
let onUsernameSelect = () => {
|
const onUsernameSelect = () => {
|
||||||
wasModifiedEvent.did_edit_un = "false";
|
wasModifiedEvent.did_edit_un = "false";
|
||||||
wasModifiedEvent.did_select_un = "true";
|
wasModifiedEvent.did_select_un = "true";
|
||||||
};
|
};
|
||||||
|
|
||||||
let onPasswordInput = () => {
|
const onPasswordInput = () => {
|
||||||
wasModifiedEvent.did_edit_pw = "true";
|
wasModifiedEvent.did_edit_pw = "true";
|
||||||
wasModifiedEvent.did_select_pw = "false";
|
wasModifiedEvent.did_select_pw = "false";
|
||||||
onInput();
|
onInput();
|
||||||
};
|
};
|
||||||
|
|
||||||
let onPasswordSelect = () => {
|
const onPasswordSelect = () => {
|
||||||
wasModifiedEvent.did_edit_pw = "false";
|
wasModifiedEvent.did_edit_pw = "false";
|
||||||
wasModifiedEvent.did_select_pw = "true";
|
wasModifiedEvent.did_select_pw = "true";
|
||||||
};
|
};
|
||||||
|
|
||||||
let onKeyUp = e => {
|
const onKeyUp = e => {
|
||||||
if (e.key == "Enter") {
|
if (e.key == "Enter") {
|
||||||
e.target.closest("popupnotification").button.doCommand();
|
e.target.closest("popupnotification").button.doCommand();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let onVisibilityToggle = commandEvent => {
|
const onVisibilityToggle = commandEvent => {
|
||||||
let passwordField = chromeDoc.getElementById(
|
const passwordField = chromeDoc.getElementById(
|
||||||
"password-notification-password"
|
"password-notification-password"
|
||||||
);
|
);
|
||||||
// Gets the caret position before changing the type of the textbox
|
// Gets the caret position before changing the type of the textbox
|
||||||
let selectionStart = passwordField.selectionStart;
|
const selectionStart = passwordField.selectionStart;
|
||||||
let selectionEnd = passwordField.selectionEnd;
|
const selectionEnd = passwordField.selectionEnd;
|
||||||
passwordField.setAttribute(
|
passwordField.setAttribute(
|
||||||
"type",
|
"type",
|
||||||
commandEvent.target.checked ? "" : "password"
|
commandEvent.target.checked ? "" : "password"
|
||||||
|
|
@ -368,14 +368,14 @@ export class LoginManagerPrompter {
|
||||||
passwordField.selectionEnd = selectionEnd;
|
passwordField.selectionEnd = selectionEnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
let togglePopup = event => {
|
const togglePopup = event => {
|
||||||
event.target.parentElement
|
event.target.parentElement
|
||||||
.getElementsByClassName("ac-has-end-icon")[0]
|
.getElementsByClassName("ac-has-end-icon")[0]
|
||||||
.toggleHistoryPopup();
|
.toggleHistoryPopup();
|
||||||
};
|
};
|
||||||
|
|
||||||
let persistData = async () => {
|
const persistData = async () => {
|
||||||
let foundLogins = lazy.LoginHelper.searchLoginsWithObject({
|
const foundLogins = lazy.LoginHelper.searchLoginsWithObject({
|
||||||
formActionOrigin: login.formActionOrigin,
|
formActionOrigin: login.formActionOrigin,
|
||||||
origin: login.origin,
|
origin: login.origin,
|
||||||
httpRealm: login.httpRealm,
|
httpRealm: login.httpRealm,
|
||||||
|
|
@ -387,7 +387,7 @@ export class LoginManagerPrompter {
|
||||||
foundLogins,
|
foundLogins,
|
||||||
autoSavedLoginGuid
|
autoSavedLoginGuid
|
||||||
);
|
);
|
||||||
let resolveBy = ["scheme", "timePasswordChanged"];
|
const resolveBy = ["scheme", "timePasswordChanged"];
|
||||||
logins = lazy.LoginHelper.dedupeLogins(
|
logins = lazy.LoginHelper.dedupeLogins(
|
||||||
logins,
|
logins,
|
||||||
["username"],
|
["username"],
|
||||||
|
|
@ -400,7 +400,7 @@ export class LoginManagerPrompter {
|
||||||
lazy.log.debug(`Matched ${logins.length} logins.`);
|
lazy.log.debug(`Matched ${logins.length} logins.`);
|
||||||
|
|
||||||
let loginToRemove;
|
let loginToRemove;
|
||||||
let loginToUpdate = logins.shift();
|
const loginToUpdate = logins.shift();
|
||||||
|
|
||||||
if (logins.length && logins[0].guid == autoSavedLoginGuid) {
|
if (logins.length && logins[0].guid == autoSavedLoginGuid) {
|
||||||
loginToRemove = logins.shift();
|
loginToRemove = logins.shift();
|
||||||
|
|
@ -470,10 +470,10 @@ export class LoginManagerPrompter {
|
||||||
PWMGR_PROMPT_UPDATE_ACTION: true,
|
PWMGR_PROMPT_UPDATE_ACTION: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mainButton = this.getLabelAndAccessKey(initialMessageIds.mainButton);
|
const mainButton = this.getLabelAndAccessKey(initialMessageIds.mainButton);
|
||||||
|
|
||||||
// The main action is the "Save" or "Update" button.
|
// The main action is the "Save" or "Update" button.
|
||||||
let mainAction = {
|
const mainAction = {
|
||||||
label: mainButton.label,
|
label: mainButton.label,
|
||||||
accessKey: mainButton.accessKey,
|
accessKey: mainButton.accessKey,
|
||||||
callback: async () => {
|
callback: async () => {
|
||||||
|
|
@ -542,11 +542,11 @@ export class LoginManagerPrompter {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let secondaryButton = this.getLabelAndAccessKey(
|
const secondaryButton = this.getLabelAndAccessKey(
|
||||||
initialMessageIds.secondaryButton
|
initialMessageIds.secondaryButton
|
||||||
);
|
);
|
||||||
|
|
||||||
let secondaryActions = [
|
const secondaryActions = [
|
||||||
{
|
{
|
||||||
label: secondaryButton.label,
|
label: secondaryButton.label,
|
||||||
accessKey: secondaryButton.accessKey,
|
accessKey: secondaryButton.accessKey,
|
||||||
|
|
@ -563,7 +563,7 @@ export class LoginManagerPrompter {
|
||||||
];
|
];
|
||||||
// Include a "Never for this site" button when saving a new password.
|
// Include a "Never for this site" button when saving a new password.
|
||||||
if (type == "password-save") {
|
if (type == "password-save") {
|
||||||
let neverSaveButton = this.getLabelAndAccessKey(
|
const neverSaveButton = this.getLabelAndAccessKey(
|
||||||
"password-manager-save-password-button-never"
|
"password-manager-save-password-button-never"
|
||||||
);
|
);
|
||||||
secondaryActions.push({
|
secondaryActions.push({
|
||||||
|
|
@ -582,7 +582,7 @@ export class LoginManagerPrompter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let updatePasswordButtonDelete = this.getLabelAndAccessKey(
|
const updatePasswordButtonDelete = this.getLabelAndAccessKey(
|
||||||
"password-manager-update-password-button-delete"
|
"password-manager-update-password-button-delete"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -617,24 +617,24 @@ export class LoginManagerPrompter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let usernamePlaceholder = lazy.l10n.formatValueSync(
|
const usernamePlaceholder = lazy.l10n.formatValueSync(
|
||||||
"password-manager-no-username-placeholder"
|
"password-manager-no-username-placeholder"
|
||||||
);
|
);
|
||||||
let togglePassword = this.getLabelAndAccessKey(
|
const togglePassword = this.getLabelAndAccessKey(
|
||||||
"password-manager-toggle-password"
|
"password-manager-toggle-password"
|
||||||
);
|
);
|
||||||
|
|
||||||
// .wrappedJSObject needed here -- see bug 422974 comment 5.
|
// .wrappedJSObject needed here -- see bug 422974 comment 5.
|
||||||
let { PopupNotifications } = browser.ownerGlobal.wrappedJSObject;
|
const { PopupNotifications } = browser.ownerGlobal.wrappedJSObject;
|
||||||
|
|
||||||
let notificationID = "password";
|
const notificationID = "password";
|
||||||
// keep attention notifications around for longer after a locationchange
|
// keep attention notifications around for longer after a locationchange
|
||||||
const timeoutMs =
|
const timeoutMs =
|
||||||
showOptions.dismissed && showOptions.extraAttr == "attention"
|
showOptions.dismissed && showOptions.extraAttr == "attention"
|
||||||
? ATTENTION_NOTIFICATION_TIMEOUT_MS
|
? ATTENTION_NOTIFICATION_TIMEOUT_MS
|
||||||
: NOTIFICATION_TIMEOUT_MS;
|
: NOTIFICATION_TIMEOUT_MS;
|
||||||
|
|
||||||
let options = Object.assign(
|
const options = Object.assign(
|
||||||
{
|
{
|
||||||
timeout: Date.now() + timeoutMs,
|
timeout: Date.now() + timeoutMs,
|
||||||
persistWhileVisible: true,
|
persistWhileVisible: true,
|
||||||
|
|
@ -682,14 +682,14 @@ export class LoginManagerPrompter {
|
||||||
login,
|
login,
|
||||||
possibleValues?.usernames
|
possibleValues?.usernames
|
||||||
).then(usernameSuggestions => {
|
).then(usernameSuggestions => {
|
||||||
let dropmarker = chromeDoc?.getElementById(
|
const dropmarker = chromeDoc?.getElementById(
|
||||||
"password-notification-username-dropmarker"
|
"password-notification-username-dropmarker"
|
||||||
);
|
);
|
||||||
if (dropmarker) {
|
if (dropmarker) {
|
||||||
dropmarker.hidden = !usernameSuggestions.length;
|
dropmarker.hidden = !usernameSuggestions.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
let usernameField = chromeDoc?.getElementById(
|
const usernameField = chromeDoc?.getElementById(
|
||||||
"password-notification-username"
|
"password-notification-username"
|
||||||
);
|
);
|
||||||
if (usernameField) {
|
if (usernameField) {
|
||||||
|
|
@ -700,7 +700,7 @@ export class LoginManagerPrompter {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let toggleBtn = chromeDoc.getElementById(
|
const toggleBtn = chromeDoc.getElementById(
|
||||||
"password-notification-visibilityToggle"
|
"password-notification-visibilityToggle"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -714,7 +714,7 @@ export class LoginManagerPrompter {
|
||||||
toggleBtn.setAttribute("label", togglePassword.label);
|
toggleBtn.setAttribute("label", togglePassword.label);
|
||||||
toggleBtn.setAttribute("accesskey", togglePassword.accessKey);
|
toggleBtn.setAttribute("accesskey", togglePassword.accessKey);
|
||||||
|
|
||||||
let hideToggle =
|
const hideToggle =
|
||||||
lazy.LoginHelper.isPrimaryPasswordSet() ||
|
lazy.LoginHelper.isPrimaryPasswordSet() ||
|
||||||
// Don't show the toggle when the login was autofilled
|
// Don't show the toggle when the login was autofilled
|
||||||
!!autoFilledLoginGuid ||
|
!!autoFilledLoginGuid ||
|
||||||
|
|
@ -744,7 +744,7 @@ export class LoginManagerPrompter {
|
||||||
case "shown": {
|
case "shown": {
|
||||||
lazy.log.debug("shown");
|
lazy.log.debug("shown");
|
||||||
writeDataToUI();
|
writeDataToUI();
|
||||||
let anchorIcon = this.anchorElement;
|
const anchorIcon = this.anchorElement;
|
||||||
if (anchorIcon && this.options.extraAttr == "attention") {
|
if (anchorIcon && this.options.extraAttr == "attention") {
|
||||||
anchorIcon.removeAttribute("extraAttr");
|
anchorIcon.removeAttribute("extraAttr");
|
||||||
delete this.options.extraAttr;
|
delete this.options.extraAttr;
|
||||||
|
|
@ -761,12 +761,12 @@ export class LoginManagerPrompter {
|
||||||
lazy.log.debug(topic);
|
lazy.log.debug(topic);
|
||||||
currentNotification = null;
|
currentNotification = null;
|
||||||
|
|
||||||
let usernameField = chromeDoc.getElementById(
|
const usernameField = chromeDoc.getElementById(
|
||||||
"password-notification-username"
|
"password-notification-username"
|
||||||
);
|
);
|
||||||
usernameField.removeEventListener("input", onUsernameInput);
|
usernameField.removeEventListener("input", onUsernameInput);
|
||||||
usernameField.removeEventListener("keyup", onKeyUp);
|
usernameField.removeEventListener("keyup", onKeyUp);
|
||||||
let passwordField = chromeDoc.getElementById(
|
const passwordField = chromeDoc.getElementById(
|
||||||
"password-notification-password"
|
"password-notification-password"
|
||||||
);
|
);
|
||||||
passwordField.removeEventListener("input", onPasswordInput);
|
passwordField.removeEventListener("input", onPasswordInput);
|
||||||
|
|
@ -784,7 +784,7 @@ export class LoginManagerPrompter {
|
||||||
showOptions
|
showOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
let notification = PopupNotifications.show(
|
const notification = PopupNotifications.show(
|
||||||
browser,
|
browser,
|
||||||
notificationID,
|
notificationID,
|
||||||
promptMessage,
|
promptMessage,
|
||||||
|
|
@ -839,7 +839,7 @@ export class LoginManagerPrompter {
|
||||||
autoFilledLoginGuid = "",
|
autoFilledLoginGuid = "",
|
||||||
possibleValues = undefined
|
possibleValues = undefined
|
||||||
) {
|
) {
|
||||||
let login = aOldLogin.clone();
|
const login = aOldLogin.clone();
|
||||||
login.origin = aNewLogin.origin;
|
login.origin = aNewLogin.origin;
|
||||||
login.formActionOrigin = aNewLogin.formActionOrigin;
|
login.formActionOrigin = aNewLogin.formActionOrigin;
|
||||||
login.password = aNewLogin.password;
|
login.password = aNewLogin.password;
|
||||||
|
|
@ -857,7 +857,7 @@ export class LoginManagerPrompter {
|
||||||
messageStringID = "password-manager-update-login-add-username";
|
messageStringID = "password-manager-update-login-add-username";
|
||||||
}
|
}
|
||||||
|
|
||||||
let notification = LoginManagerPrompter._showLoginCaptureDoorhanger(
|
const notification = LoginManagerPrompter._showLoginCaptureDoorhanger(
|
||||||
aBrowser,
|
aBrowser,
|
||||||
login,
|
login,
|
||||||
"password-change",
|
"password-change",
|
||||||
|
|
@ -874,7 +874,7 @@ export class LoginManagerPrompter {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let oldGUID = aOldLogin.QueryInterface(Ci.nsILoginMetaInfo).guid;
|
const oldGUID = aOldLogin.QueryInterface(Ci.nsILoginMetaInfo).guid;
|
||||||
Services.obs.notifyObservers(
|
Services.obs.notifyObservers(
|
||||||
aNewLogin,
|
aNewLogin,
|
||||||
"passwordmgr-prompt-change",
|
"passwordmgr-prompt-change",
|
||||||
|
|
@ -883,7 +883,7 @@ export class LoginManagerPrompter {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dismiss() {
|
dismiss() {
|
||||||
let { PopupNotifications } = aBrowser.ownerGlobal.wrappedJSObject;
|
const { PopupNotifications } = aBrowser.ownerGlobal.wrappedJSObject;
|
||||||
PopupNotifications.remove(notification);
|
PopupNotifications.remove(notification);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -1047,20 +1047,20 @@ export class LoginManagerPrompter {
|
||||||
* @param {Set<String>?} possibleUsernames - values that we believe may be new/changed login usernames.
|
* @param {Set<String>?} possibleUsernames - values that we believe may be new/changed login usernames.
|
||||||
*/
|
*/
|
||||||
static async _setUsernameAutocomplete(login, possibleUsernames = new Set()) {
|
static async _setUsernameAutocomplete(login, possibleUsernames = new Set()) {
|
||||||
let result = Cc["@mozilla.org/autocomplete/simple-result;1"].createInstance(
|
const result = Cc[
|
||||||
Ci.nsIAutoCompleteSimpleResult
|
"@mozilla.org/autocomplete/simple-result;1"
|
||||||
);
|
].createInstance(Ci.nsIAutoCompleteSimpleResult);
|
||||||
result.setDefaultIndex(0);
|
result.setDefaultIndex(0);
|
||||||
|
|
||||||
let usernames = await this._getUsernameSuggestions(
|
const usernames = await this._getUsernameSuggestions(
|
||||||
login,
|
login,
|
||||||
possibleUsernames
|
possibleUsernames
|
||||||
);
|
);
|
||||||
for (let { text, style } of usernames) {
|
for (const { text, style } of usernames) {
|
||||||
let value = text;
|
const value = text;
|
||||||
let comment = "";
|
const comment = "";
|
||||||
let image = "";
|
const image = "";
|
||||||
let _style = style;
|
const _style = style;
|
||||||
result.appendMatch(value, comment, image, _style);
|
result.appendMatch(value, comment, image, _style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1090,28 +1090,28 @@ export class LoginManagerPrompter {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
let baseDomainLogins = await Services.logins.searchLoginsAsync({
|
const baseDomainLogins = await Services.logins.searchLoginsAsync({
|
||||||
origin: login.origin,
|
origin: login.origin,
|
||||||
schemeUpgrades: lazy.LoginHelper.schemeUpgrades,
|
schemeUpgrades: lazy.LoginHelper.schemeUpgrades,
|
||||||
acceptDifferentSubdomains: true,
|
acceptDifferentSubdomains: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
let saved = baseDomainLogins.map(login => {
|
const saved = baseDomainLogins.map(login => {
|
||||||
return { text: login.username, style: "login" };
|
return { text: login.username, style: "login" };
|
||||||
});
|
});
|
||||||
let possible = [...possibleUsernames].map(username => {
|
const possible = [...possibleUsernames].map(username => {
|
||||||
return { text: username, style: "possible-username" };
|
return { text: username, style: "possible-username" };
|
||||||
});
|
});
|
||||||
|
|
||||||
return possible
|
return possible
|
||||||
.concat(saved)
|
.concat(saved)
|
||||||
.reduce((acc, next) => {
|
.reduce((acc, next) => {
|
||||||
let alreadyInAcc =
|
const alreadyInAcc =
|
||||||
acc.findIndex(entry => entry.text == next.text) != -1;
|
acc.findIndex(entry => entry.text == next.text) != -1;
|
||||||
if (!alreadyInAcc) {
|
if (!alreadyInAcc) {
|
||||||
acc.push(next);
|
acc.push(next);
|
||||||
} else if (next.style == "possible-username") {
|
} else if (next.style == "possible-username") {
|
||||||
let existingIndex = acc.findIndex(entry => entry.text == next.text);
|
const existingIndex = acc.findIndex(entry => entry.text == next.text);
|
||||||
acc[existingIndex] = next;
|
acc[existingIndex] = next;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue