Bug 1135451 - fillForm() cleanup part H: rename isFormDisabled to be obvious as to purpose. r=MattN
authorJustin Dolske <dolske@mozilla.com>
Fri, 27 Feb 2015 15:47:37 -0800
changeset 231349 a80f93233b34c0ffea8e8ba0668097a40c7d0970
parent 231348 c918b8a2b9c0aa6277728f36882db829cd1aa7d8
child 231350 beba8a0f7c8d0d5575793b9aab166f3de85af6ac
push id28349
push userkwierso@gmail.com
push dateMon, 02 Mar 2015 20:41:54 +0000
treeherdermozilla-central@eaaa45f32e9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1135451
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1135451 - fillForm() cleanup part H: rename isFormDisabled to be obvious as to purpose. r=MattN
toolkit/components/passwordmgr/LoginManagerContent.jsm
--- a/toolkit/components/passwordmgr/LoginManagerContent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm
@@ -632,16 +632,23 @@ 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");
         recordAutofillResult(AUTOFILL_RESULT.PASSWORD_DISABLED_READONLY);
         return;
       }
 
+      var isAutocompleteOff = false;
+      if (this._isAutocompleteDisabled(form) ||
+          this._isAutocompleteDisabled(usernameField) ||
+          this._isAutocompleteDisabled(passwordField)) {
+        isAutocompleteOff = true;
+      }
+
       // Discard logins which have username/password values that don't
       // fit into the fields (as specified by the maxlength attribute).
       // The user couldn't enter these values anyway, and it helps
       // with sites that have an extra PIN to be entered (bug 391514)
       var maxUsernameLen = Number.MAX_VALUE;
       var maxPasswordLen = Number.MAX_VALUE;
 
       // If attribute wasn't set, default is -1.
@@ -673,30 +680,16 @@ var LoginManagerContent = {
 
       // Don't clobber an existing password.
       if (passwordField.value && !clobberPassword) {
         log("form not filled, the password field was already filled");
         recordAutofillResult(AUTOFILL_RESULT.EXISTING_PASSWORD);
         return;
       }
 
-      // If the form has an autocomplete=off attribute in play, don't
-      // fill in the login automatically. We check this after attaching
-      // the autocomplete stuff to the username field, so the user can
-      // still manually select a login to be filled in.
-      var isFormDisabled = false;
-      if (!ignoreAutocomplete &&
-          (this._isAutocompleteDisabled(form) ||
-           this._isAutocompleteDisabled(usernameField) ||
-           this._isAutocompleteDisabled(passwordField))) {
-
-        isFormDisabled = true;
-        log("form not filled, has autocomplete=off");
-      }
-
       // Select a login to use for filling in the form.
       var selectedLogin;
       if (usernameField && (usernameField.value || usernameField.disabled || usernameField.readOnly)) {
         // If username was specified in the field, it's disabled or it's readOnly, only fill in the
         // password if we find a matching login.
         var username = usernameField.value.toLowerCase();
 
         let matchingLogins = logins.filter(function(l)
@@ -737,23 +730,23 @@ var LoginManagerContent = {
         }
 
         selectedLogin = matchingLogins[0];
       }
 
       // We will always have a selectedLogin at this point.
 
       if (!autofillForm) {
-        log("autofillForms=false but form can be filled; notified observers");
+        log("autofillForms=false but form can be filled");
         recordAutofillResult(AUTOFILL_RESULT.NO_AUTOFILL_FORMS);
         return;
       }
 
-      if (isFormDisabled) {
-        log("autocomplete=off but form can be filled; notified observers");
+      if (isAutocompleteOff && !ignoreAutocomplete) {
+        log("Not filling the login because we're respecting autocomplete=off");
         recordAutofillResult(AUTOFILL_RESULT.AUTOCOMPLETE_OFF);
         return;
       }
 
       // Fill the form
 
       if (usernameField) {
       // Don't modify the username field if it's disabled or readOnly so we preserve its case.