Google-chrome – Password memorization and autocomplete heuristics in Chrome

autocompleteformsgoogle-chromepassword-management

What are Chrome's heuristics to decide to save login form data and autocomplete them on the next visit?

If Chrome isn't saving the credentials on a particular form, what could the reasons be? I know that:

Experimentally, this is not enough: I have a login page (private, sorry, but the gist of the code is below) that meets both criteria and where the credentials aren't autocompleted.


Here's my specific problem. I've solved it another way (by installing Autofill and making it enter my credentials on the form), but I'd still like to know why Chrome isn't offering to save the credentials.

A website (not written by me, and not publicly accessible) requires a username and password. It uses a fairly standard-looking (to my uninformed eyes) form, which looks like this (I've omitted a lot of nested <div> and whatnot, and attributes and functions shown here as fooXXX were renamed by me).

<form name="aspnetForm" method="post" action="default.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">
  <table>
    <tr>
      <td>Username:</td>
      <td><input name="foo$name" type="text" id="foo_name" tabindex="1" autocomplete="off" onkeyup="fooFunction()" style="width:175px;" /></td>
    </tr>
    <tr>
      <td>Password:</td>
      <td><input name="foo@pass" type="password" id="foo_pass" tabindex="2" value="" autocomplete="off" style="width:175px;" /></td>
    </tr>
  </table>
</form>

I want my browser to remember my credentials for this site. The feature is enabled in the browser, but there's something peculiar about this site that causes both Firefox and Chrome not to offer to remember the name and password.

I wrote a userscript (Greasemonkey script in Firefox, unpacked extension in Chrome) to change autocomplete="off" to autocomplete="on":

document.querySelector("#foo_user").setAttribute("autocomplete", "on");
document.querySelector("#foo_pass").setAttribute("autocomplete", "on");

In Firefox, this has the desired effect: Firefox offers to remember the password, and the next time I visit the login page my credentials are autofilled.

No such luck in Chrome (27.0.1453.93, Linux). I don't get prompted to remember the password and don't get a history for the username field. I have confirmed that the script is executed by inspecting the input elements, they do show autocomplete="on".

I tried adding these lines to my userscript, but they don't improve the situation.

document.querySelector("#foo_user").removeAttribute("onkeyup");
document.querySelector("#foo_pass").removeAttribute("value");

How do Chrome's heuristics differ from Firefox, and how do I get it to remember my credentials?

Best Answer

Use the autocomplete=on extension.

Changes 'autocomplete=off' to 'autocomplete=on' in web pages, so your passwords will be remembered.