Bug 1318203 - Don't show autocomplete UI on Password Field if it is already populated with text, r=MattN a=jcristau
authorTimothy Guan-tin Chien <timdream@gmail.com>
Tue, 03 Jan 2017 11:45:30 -0500
changeset 353319 917b84b3b941b70c9cc29847f43bfe6b8731ec20
parent 353318 98f702a24bea42d7e3f248cdaa74b66daf83a17e
child 353320 b32127935d3835505115e296afd745a302367b7f
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, jcristau
bugs1318203
milestone52.0a2
Bug 1318203 - Don't show autocomplete UI on Password Field if it is already populated with text, r=MattN a=jcristau MozReview-Commit-ID: L3cUxHYIE5R
toolkit/components/passwordmgr/nsLoginManager.js
--- a/toolkit/components/passwordmgr/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/nsLoginManager.js
@@ -497,43 +497,44 @@ LoginManager.prototype = {
       let results = new UserAutoCompleteResult(aSearchString, logins, {
         messageManager,
         isSecure,
         isPasswordField,
       });
       aCallback.onSearchCompletion(results);
     };
 
-    if (isPasswordField) {
-      // The login items won't be filtered for password field.
-      aSearchString = "";
+    if (isPasswordField && aSearchString) {
+      // Return empty result on password fields with password already filled.
+      let acLookupPromise = this._autoCompleteLookupPromise = Promise.resolve({ logins: [] });
+      acLookupPromise.then(completeSearch.bind(this, acLookupPromise));
+      return;
     }
 
     if (!this._remember) {
-      setTimeout(function() {
-        aCallback.onSearchCompletion(new UserAutoCompleteResult(aSearchString, [], {isSecure}));
-      }, 0);
+      let acLookupPromise = this._autoCompleteLookupPromise = Promise.resolve({ logins: [] });
+      acLookupPromise.then(completeSearch.bind(this, acLookupPromise));
       return;
     }
 
     log.debug("AutoCompleteSearch invoked. Search is:", aSearchString);
 
     let previousResult;
     if (aPreviousResult) {
       previousResult = { searchString: aPreviousResult.searchString,
                          logins: aPreviousResult.wrappedJSObject.logins };
     } else {
       previousResult = null;
     }
 
     let rect = BrowserUtils.getElementBoundingScreenRect(aElement);
-    let autoCompleteLookupPromise = this._autoCompleteLookupPromise =
+    let acLookupPromise = this._autoCompleteLookupPromise =
       LoginManagerContent._autoCompleteSearchAsync(aSearchString, previousResult,
                                                    aElement, rect);
-    autoCompleteLookupPromise.then(completeSearch.bind(this, autoCompleteLookupPromise))
+    acLookupPromise.then(completeSearch.bind(this, acLookupPromise))
                              .then(null, Cu.reportError);
   },
 
   stopSearch() {
     this._autoCompleteLookupPromise = null;
   },
 }; // end of LoginManager implementation