7

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?

3
  • 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
    Jun 6, 2013 at 18:36
  • @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. Jun 6, 2013 at 18:42
  • Based on the comments on this question superuser.com/questions/457310/… 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. Aug 15, 2013 at 3:22

2 Answers 2

1

Use the autocomplete=on extension.

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

2
  • 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
    Jun 6, 2013 at 18:47
  • 1
    As expected, it makes no difference. I'm already doing the same thing this extension does. @MattDMo This is Chrome, userscript = extension. Jun 6, 2013 at 18:55
1

I found a flag that seems to solve the problem of autocomplete while looking for new flags. In chrome://flags, there's a flag named "Enable login detection". Flip that to "Disabled", and it should (at least until the experiment is removed) solve your issue. (On Chrome for iOS, this flag does not exist! So, on that platform, you're stuck!) And as for what the answer is to what Google uses, my bet is that it uses intents like those for the Omnibox, where you can see history, but I'm not sure of that! Regards, Mac

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.