Bug 1538458 - Part 1. LoginManagerContent requires <input> or <input type="password"> element to recognize login form r=geckoview-reviewers,snorp
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 07 May 2019 20:18:12 +0000
changeset 532004 b0c3aa221224b5f3c6f60079756791a04fe33602
parent 532003 9ba1d1d1f4442047a0cc53cc8e006c0bc2c2d7f7
child 532005 84191877561ed6ad1e5905b703c2c5865836c45b
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, snorp
bugs1538458
milestone68.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 1538458 - Part 1. LoginManagerContent requires <input> or <input type="password"> element to recognize login form r=geckoview-reviewers,snorp Actually, sample url has `<fieldset>` element, so LoginManagerContent cannot detects username field. `LoginManagerContent.getUserNameAndPasswordFields` detects username field and password field when passing `<input>` element. So we should pass password field if possible. Differential Revision: https://phabricator.services.mozilla.com/D30179
mobile/android/modules/geckoview/GeckoViewAutoFill.jsm
--- a/mobile/android/modules/geckoview/GeckoViewAutoFill.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewAutoFill.jsm
@@ -116,18 +116,29 @@ class GeckoViewAutoFill {
       }
 
       this._autoFillInfos.set(element, info);
       this._autoFillElements.set(info.id, Cu.getWeakReference(element));
       sendFocusEvent |= (element === element.ownerDocument.activeElement);
       return info;
     };
 
+    // Get password field to get better form data via LoginManagerContent.
+    let passwordField;
+    for (const field of aFormLike.elements) {
+      if (ChromeUtils.getClassName(field) === "HTMLInputElement" &&
+          field.type == "password") {
+        passwordField = field;
+        break;
+      }
+    }
+
     const [usernameField] =
-      LoginManagerContent.getUserNameAndPasswordFields(aFormLike.elements[0]);
+      LoginManagerContent.getUserNameAndPasswordFields(
+        passwordField || aFormLike.elements[0]);
 
     const rootInfo = getInfo(aFormLike.rootElement, null, undefined, null);
     rootInfo.root = rootInfo.id;
     rootInfo.children = aFormLike.elements
         .filter(element => (!usernameField || element.type != "text" ||
                             element == usernameField))
         .map(element => getInfo(element, rootInfo.id, rootInfo.id, usernameField));