Bug 1386283 - Only consider connected <input>s for username/password fields. r=mconley
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Thu, 10 Jan 2019 19:25:01 +0000
changeset 510433 d5357c40725c706cb66e6ac7dce04f7821666c75
parent 510432 15895cfafac18c606afcfac68d89cc4f3653d065
child 510434 c39b7fb8bbdd2807f898c59fdbfcf1f528398c89
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1386283
milestone66.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 1386283 - Only consider connected <input>s for username/password fields. r=mconley Differential Revision: https://phabricator.services.mozilla.com/D15887
toolkit/components/passwordmgr/LoginHelper.jsm
toolkit/components/passwordmgr/LoginManagerContent.jsm
--- a/toolkit/components/passwordmgr/LoginHelper.jsm
+++ b/toolkit/components/passwordmgr/LoginHelper.jsm
@@ -563,16 +563,22 @@ var LoginHelper = {
    *
    * @returns {Boolean} true if the field type is one
    *                    of the username types.
    */
   isUsernameFieldType(element) {
     if (ChromeUtils.getClassName(element) !== "HTMLInputElement")
       return false;
 
+    if (!element.isConnected) {
+      // If the element isn't connected then it isn't visible to the user so
+      // shouldn't be considered. It must have been connected in the past.
+      return false;
+    }
+
     let fieldType = (element.hasAttribute("type") ?
                      element.getAttribute("type").toLowerCase() :
                      element.type);
     if (fieldType == "text" ||
         fieldType == "email" ||
         fieldType == "url" ||
         fieldType == "tel" ||
         fieldType == "number") {
--- a/toolkit/components/passwordmgr/LoginManagerContent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm
@@ -671,17 +671,18 @@ var LoginManagerContent = {
     fieldOverrideRecipe = null,
     skipEmptyFields = false,
   } = {}) {
     // Locate the password fields in the form.
     let pwFields = [];
     for (let i = 0; i < form.elements.length; i++) {
       let element = form.elements[i];
       if (ChromeUtils.getClassName(element) !== "HTMLInputElement" ||
-          element.type != "password") {
+          element.type != "password" ||
+          !element.isConnected) {
         continue;
       }
 
       // Exclude ones matching a `notPasswordSelector`, if specified.
       if (fieldOverrideRecipe && fieldOverrideRecipe.notPasswordSelector &&
           element.matches(fieldOverrideRecipe.notPasswordSelector)) {
         log("skipping password field (id/name is", element.id, " / ",
             element.name + ") due to recipe:", fieldOverrideRecipe);