Backed out changeset 678b0803aa1c (bug 1330111)

This commit is contained in:
Carsten "Tomcat" Book 2017-02-07 14:03:17 +01:00
parent 57860c8f8f
commit ec522e91ed

View File

@ -922,8 +922,6 @@ var LoginManagerContent = {
userTriggered, foundLogins, recipes, {inputElement} = {}) {
log("_fillForm", form.elements);
let ignoreAutocomplete = true;
// Will be set to one of AUTOFILL_RESULT in the `try` block.
let autofillResult = -1;
const AUTOFILL_RESULT = {
FILLED: 0,
NO_PASSWORD_FIELD: 1,
@ -938,6 +936,15 @@ var LoginManagerContent = {
INSECURE: 10,
};
function recordAutofillResult(result) {
if (userTriggered) {
// Ignore fills as a result of user action.
return;
}
const autofillResultHist = Services.telemetry.getHistogramById("PWMGR_FORM_AUTOFILL_RESULT");
autofillResultHist.add(result);
}
try {
// Nothing to do if we have no matching logins available,
// and there isn't a need to show the insecure form warning.
@ -945,7 +952,7 @@ var LoginManagerContent = {
(InsecurePasswordUtils.isFormSecure(form) ||
!LoginHelper.showInsecureFieldWarning)) {
// We don't log() here since this is a very common case.
autofillResult = AUTOFILL_RESULT.NO_SAVED_LOGINS;
recordAutofillResult(AUTOFILL_RESULT.NO_SAVED_LOGINS);
return;
}
@ -975,7 +982,7 @@ var LoginManagerContent = {
// Need a valid password field to do anything.
if (passwordField == null) {
log("not filling form, no password field found");
autofillResult = AUTOFILL_RESULT.NO_PASSWORD_FIELD;
recordAutofillResult(AUTOFILL_RESULT.NO_PASSWORD_FIELD);
return;
}
@ -984,7 +991,7 @@ var LoginManagerContent = {
// If the password field is disabled or read-only, there's nothing to do.
if (passwordField.disabled || passwordField.readOnly) {
log("not filling form, password field disabled or read-only");
autofillResult = AUTOFILL_RESULT.PASSWORD_DISABLED_READONLY;
recordAutofillResult(AUTOFILL_RESULT.PASSWORD_DISABLED_READONLY);
return;
}
@ -1002,7 +1009,7 @@ var LoginManagerContent = {
// telemetry flag.
if (foundLogins.length == 0) {
// We don't log() here since this is a very common case.
autofillResult = AUTOFILL_RESULT.NO_SAVED_LOGINS;
recordAutofillResult(AUTOFILL_RESULT.NO_SAVED_LOGINS);
return;
}
@ -1010,7 +1017,7 @@ var LoginManagerContent = {
if (!userTriggered && !LoginHelper.insecureAutofill &&
!InsecurePasswordUtils.isFormSecure(form)) {
log("not filling form since it's insecure");
autofillResult = AUTOFILL_RESULT.INSECURE;
recordAutofillResult(AUTOFILL_RESULT.INSECURE);
return;
}
@ -1045,14 +1052,14 @@ var LoginManagerContent = {
if (logins.length == 0) {
log("form not filled, none of the logins fit in the field");
autofillResult = AUTOFILL_RESULT.NO_LOGINS_FIT;
recordAutofillResult(AUTOFILL_RESULT.NO_LOGINS_FIT);
return;
}
// Don't clobber an existing password.
if (passwordField.value && !clobberPassword) {
log("form not filled, the password field was already filled");
autofillResult = AUTOFILL_RESULT.EXISTING_PASSWORD;
recordAutofillResult(AUTOFILL_RESULT.EXISTING_PASSWORD);
return;
}
@ -1069,7 +1076,7 @@ var LoginManagerContent = {
l.username.toLowerCase() == username);
if (matchingLogins.length == 0) {
log("Password not filled. None of the stored logins match the username already present.");
autofillResult = AUTOFILL_RESULT.EXISTING_USERNAME;
recordAutofillResult(AUTOFILL_RESULT.EXISTING_USERNAME);
return;
}
@ -1098,7 +1105,7 @@ var LoginManagerContent = {
if (matchingLogins.length != 1) {
log("Multiple logins for form, so not filling any.");
autofillResult = AUTOFILL_RESULT.MULTIPLE_LOGINS;
recordAutofillResult(AUTOFILL_RESULT.MULTIPLE_LOGINS);
return;
}
@ -1109,13 +1116,13 @@ var LoginManagerContent = {
if (!autofillForm) {
log("autofillForms=false but form can be filled");
autofillResult = AUTOFILL_RESULT.NO_AUTOFILL_FORMS;
recordAutofillResult(AUTOFILL_RESULT.NO_AUTOFILL_FORMS);
return;
}
if (isAutocompleteOff && !ignoreAutocomplete) {
log("Not filling the login because we're respecting autocomplete=off");
autofillResult = AUTOFILL_RESULT.AUTOCOMPLETE_OFF;
recordAutofillResult(AUTOFILL_RESULT.AUTOCOMPLETE_OFF);
return;
}
@ -1141,22 +1148,12 @@ var LoginManagerContent = {
}
log("_fillForm succeeded");
autofillResult = AUTOFILL_RESULT.FILLED;
recordAutofillResult(AUTOFILL_RESULT.FILLED);
let doc = form.ownerDocument;
let win = doc.defaultView;
let messageManager = messageManagerFromWindow(win);
messageManager.sendAsyncMessage("LoginStats:LoginFillSuccessful");
} finally {
if (autofillResult == -1) {
// eslint-disable-next-line no-unsafe-finally
throw new Error("_fillForm: autofillResult must be specified");
}
if (!userTriggered) {
// Ignore fills as a result of user action for this probe.
Services.telemetry.getHistogramById("PWMGR_FORM_AUTOFILL_RESULT").add(autofillResult);
}
Services.obs.notifyObservers(form.rootElement, "passwordmgr-processed-form", null);
}
},