Bug 1318203 - Don't show autocomplete UI on Password Field if it is already populated with text, r=MattN
MozReview-Commit-ID: L3cUxHYIE5R
--- a/toolkit/components/passwordmgr/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/nsLoginManager.js
@@ -480,25 +480,44 @@ LoginManager.prototype = {
autoCompleteSearchAsync(aSearchString, aPreviousResult,
aElement, aCallback) {
// aPreviousResult is an nsIAutoCompleteResult, aElement is
// nsIDOMHTMLInputElement
let form = LoginFormFactory.createFromField(aElement);
let isSecure = InsecurePasswordUtils.isFormSecure(form);
let isPasswordField = aElement.type == "password";
- 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 autoCompleteLookupPromise =
+ this._autoCompleteLookupPromise = Promise.resolve();
+ autoCompleteLookupPromise.then(() => {
+ // If the search was canceled before we got our
+ // results, don't bother reporting them.
+ if (this._autoCompleteLookupPromise !== autoCompleteLookupPromise) {
+ return;
+ }
+ this._autoCompleteLookupPromise = null;
+ aCallback.onSearchCompletion(new UserAutoCompleteResult(aSearchString, [], {isSecure, isPasswordField}));
+ });
+ return;
}
if (!this._remember) {
- setTimeout(function() {
- aCallback.onSearchCompletion(new UserAutoCompleteResult(aSearchString, [], {isSecure}));
- }, 0);
+ let autoCompleteLookupPromise =
+ this._autoCompleteLookupPromise = Promise.resolve();
+ autoCompleteLookupPromise.then(() => {
+ // If the search was canceled before we got our
+ // results, don't bother reporting them.
+ if (this._autoCompleteLookupPromise !== autoCompleteLookupPromise) {
+ return;
+ }
+ this._autoCompleteLookupPromise = null;
+ aCallback.onSearchCompletion(new UserAutoCompleteResult(aSearchString, [], {isSecure, isPasswordField}));
+ });
return;
}
log.debug("AutoCompleteSearch invoked. Search is:", aSearchString);
let previousResult;
if (aPreviousResult) {
previousResult = { searchString: aPreviousResult.searchString,