Bug 576022 - Password Manager does not fill in password immediately after selecting username [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 30 Jun 2010 22:22:45 -0400
changeset 1693 d0c7ca14452eac19f8a37ca5d164a387c0f4314a
parent 1692 e00914979039ef072f3a2f76cd75fec4fbf73d00
child 1694 32ccee63473958d4c8539d445cea3ccc54fc63fa
push id1520
push usermfinkle@mozilla.com
push dateThu, 01 Jul 2010 02:25:13 +0000
reviewersmfinkle
bugs576022
Bug 576022 - Password Manager does not fill in password immediately after selecting username [r=mfinkle]
chrome/content/forms.js
--- a/chrome/content/forms.js
+++ b/chrome/content/forms.js
@@ -176,17 +176,16 @@ FormAssistant.prototype = {
         this.goToPrevious();
         sendAsyncMessage("FormAssist:Show", this.getJSON());
         break;
 
       case aEvent.DOM_VK_RETURN:
         break;
 
       default:
-        let target = aEvent.target;
         if (currentWrapper.canAutocomplete())
           sendAsyncMessage("FormAssist:AutoComplete", this.getJSON());
         break;
     }
 
     let caretRect = currentWrapper.getCaretRect();
     if (!caretRect.isEmpty()) {
       sendAsyncMessage("FormAssist:Update", { caretRect: caretRect });
@@ -377,16 +376,20 @@ BasicWrapper.prototype = {
 
   /** Element is capable of having autocomplete suggestions. */
   canAutocomplete: function() {
     return this.element instanceof HTMLInputElement;
   },
 
   autocomplete: function(aValue) {
     this.element.value = aValue;
+
+    let event = this.element.ownerDocument.createEvent("Events");
+    event.initEvent("DOMAutoComplete", true, true);
+    this.element.dispatchEvent(event);
   },
 
   /** Caret is used to input text for this element. */
   getCaretRect: function() {
     let element = this.element;
     if ((element instanceof HTMLTextAreaElement ||
         (element instanceof HTMLInputElement && element.type == "text")) &&
         gFocusManager.focusedElement == element) {
@@ -566,17 +569,17 @@ SelectWrapper.prototype = {
   },
 
   fireOnChange: function() {
     let control = this._control;
     let evt = this._control.ownerDocument.createEvent("Events");
     evt.initEvent("change", true, true, this._control.ownerDocument.defaultView, 0,
                   false, false,
                   false, false, null);
-    content.document.defaultView.setTimeout(function() {
+    content.setTimeout(function() {
       control.dispatchEvent(evt);
     }, 0);
   }
 };
 
 
 // bug 559792
 // Use wrappedJSObject when control is in content for extra protection
@@ -627,14 +630,14 @@ MenulistWrapper.prototype = {
   },
 
   fireOnChange: function() {
     let control = this._control;
     let evt = document.createEvent("XULCommandEvent");
     evt.initCommandEvent("command", true, true, window, 0,
                          false, false,
                          false, false, null);
-    content.document.defaultView.setTimeout(function() {
+    content.setTimeout(function() {
       control.dispatchEvent(evt);
     }, 0);
   }
 };