Bug 1293513 - Only setup login manager's progress listener for formless passwords inputs. draft
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Mon, 15 Aug 2016 16:13:53 -0700
changeset 400840 64c4aed441b9452b579f21c666ba5f088535c611
parent 397822 e78975b53563d80c99ebfbdf8a9fbf6b829a8a48
child 528340 0aa89197729fef12f9a6a719bf6ba50a5bc6dee7
push id26296
push usermozilla@noorenberghe.ca
push dateMon, 15 Aug 2016 23:15:29 +0000
bugs1293513
milestone51.0a1
Bug 1293513 - Only setup login manager's progress listener for formless passwords inputs. MozReview-Commit-ID: GQtMX15ShsR
toolkit/components/passwordmgr/LoginManagerContent.jsm
--- a/toolkit/components/passwordmgr/LoginManagerContent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm
@@ -100,17 +100,21 @@ var observer = {
     }
 
     // Don't handle history navigation, reload, or pushState not triggered via chrome UI.
     // e.g. history.go(-1), location.reload(), history.replaceState()
     if (!(aWebProgress.loadType & Ci.nsIDocShell.LOAD_CMD_NORMAL)) {
       log("onStateChange: loadType isn't LOAD_CMD_NORMAL:", aWebProgress.loadType);
       return;
     }
-
+/*
+    for (let state of ["STATE_IS_REQUEST", "STATE_IS_DOCUMENT", "STATE_IS_NETWORK", "STATE_IS_WINDOW"]) {
+      log(state, !!(aState & Ci.nsIWebProgressListener[state]));
+    }
+*/
     log("onStateChange handled:", channel);
     LoginManagerContent._onNavigation(aWebProgress.DOMWindow.document);
   },
 };
 
 Services.obs.addObserver(observer, "earlyformsubmit", false);
 var prefBranch = Services.prefs.getBranch("signon.");
 prefBranch.addObserver("", observer.onPrefChange, false);
@@ -328,16 +332,17 @@ var LoginManagerContent = {
       let webProgress = window.QueryInterface(Ci.nsIInterfaceRequestor).
                         getInterface(Ci.nsIWebNavigation).
                         QueryInterface(Ci.nsIDocShell).
                         QueryInterface(Ci.nsIInterfaceRequestor).
                         getInterface(Ci.nsIWebProgress);
       webProgress.addProgressListener(observer,
                                       Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT |
                                       Ci.nsIWebProgress.NOTIFY_LOCATION);
+      log("setupProgressListener succeeded for", window.location.href);
     } catch (ex) {
       // Ignore NS_ERROR_FAILURE if the progress listener was already added
     }
   },
 
   onDOMFormHasPassword(event, window) {
     if (!event.isTrusted) {
       return;
@@ -349,24 +354,26 @@ var LoginManagerContent = {
     this._fetchLoginsFromParentAndFillForm(formLike, window);
   },
 
   onDOMInputPasswordAdded(event, window) {
     if (!event.isTrusted) {
       return;
     }
 
-    this.setupProgressListener(window);
-
     let pwField = event.target;
     if (pwField.form) {
-      // Handled by onDOMFormHasPassword which is already throttled.
+      // Fill is handled by onDOMFormHasPassword which is already throttled.
       return;
     }
 
+    // Only setup the listener for formless inputs.
+    // Capture within a <form> but without a submit event is bug 1287202.
+    this.setupProgressListener(window);
+
     let formLike = FormLikeFactory.createFromField(pwField);
     log("onDOMInputPasswordAdded:", pwField, formLike);
 
     let deferredTask = this._deferredPasswordAddedTasksByRootElement.get(formLike.rootElement);
     if (!deferredTask) {
       log("Creating a DeferredTask to call _fetchLoginsFromParentAndFillForm soon");
       this._formLikeByRootElement.set(formLike.rootElement, formLike);