Password memorization and autocomplete heuristics in Chrome

6

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?

Gilles 'SO- stop being evil'

Posted 2013-06-06T18:30:25.277

Reputation: 58 319

What does fooFunction() do? Might it be changing the autocomplete attribute back on? What happens if you change your userscript to document.querySelector("#foo_user").removeAttribute("autocomplete"); (and the same for #foo_pass)? Finally, can you change the time at which the userscript runs? It might be that Chrome has already evaluated whether or not to autocomplete a field before your userscript has run. – MattDMo – 2013-06-06T18:36:44.230

@MattDMo fooFunction only applies some capitalization rules to the username (don't ask me why — the username is case-insensitive server-side!). In any case removing the onkeyup attribute didn't help. I also tried removing the autocomplete attribute altogether (did that first, in fact), without success. I have no idea how I would change the time at which the userscript runs. – Gilles 'SO- stop being evil' – 2013-06-06T18:42:27.510

Based on the comments on this question http://superuser.com/questions/457310/how-to-override-a-website-blocking-autocomplete-on-forms-google-chrome it doesn't seem like you can get Google Chrome to do what you want. But there isn't any explanation on that question, so I don't know what Chrome's actual criteria are, which is what you wanted to know.

– Ellie Kesselman – 2013-08-15T03:22:14.230

Answers

1

Use the autocomplete=on extension.

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

stderr

Posted 2013-06-06T18:30:25.277

Reputation: 9 300

This looks like it could work - hopefully it gets executed before the userscript, and the value isn't dynamically changed back later in the page loading process. – MattDMo – 2013-06-06T18:47:46.397

1As expected, it makes no difference. I'm already doing the same thing this extension does. @MattDMo This is Chrome, userscript = extension. – Gilles 'SO- stop being evil' – 2013-06-06T18:55:55.790