1

I have been wondering (and checked the Bitwarden chrome extension source code but couldn't figure out): how do password managers fill in your passwords?

What I'm trying to say is: some websites require certain events to be fired, such as blur, before they see a field as "filled in".

I tried filling in an e-mail address at this website for example: https://www.scoodle.be/login

When bitwarden fills in my e-mail address and I click on "Log in", it works fine (as expected). However, when I issue the following commands on the console:

document.querySelector('input[type="email"]').value="my@email.com";
document.querySelector('button[type="submit"]').click()

It says "Vul een e-mail adres in" (In english: Fill in an e-mail address)

What is the "magic" that password managers are using so the website does detect the value being put in? I thought it would have to do something with events, but I've fired all of them on the input that I could find... (don't worry about elem, it refers to the document.querySelector(...) above, this was added afterwards)

elem.dispatchEvent(new Event('compositionend'));
elem.dispatchEvent(new Event('compositionstart'));
elem.dispatchEvent(new Event('compositionupdat'));
elem.dispatchEvent(new Event('focus'));
elem.dispatchEvent(new Event('focusin'));
elem.dispatchEvent(new Event('blur'));
elem.dispatchEvent(new Event('focusout'));
elem.dispatchEvent(new Event('keydown'));
elem.dispatchEvent(new Event('keypress'));
elem.dispatchEvent(new Event('keyup'));
elem.dispatchEvent(new Event('mouseenter'));
elem.dispatchEvent(new Event('mousedown'));
elem.dispatchEvent(new Event('mouseup'));
elem.dispatchEvent(new Event('mouseleave'));
elem.dispatchEvent(new Event('mouseout'));

I figured I'd add some mouse events as well cause why not, but none of them is the lucky one Source: https://developer.mozilla.org/en-US/docs/Web/API/Element#events

Am I overlooking something stupid, or..

Posts I have checked and that did not answer my question

  1. VueJs - Password managers detection They're trying to make their website compatible with a password manager, but that doesn't answer my question.
  2. How do password managers know when I've logged in successfully? This post is asking how password managers detect when you've logged in succesfully. Not about filling the fields in.
  3. How do password managers autofill email and password inputs on all sites? A comment claims that password managers have been specifically "trained" for "weird" sites. Although this seems very unlikely as some websites I've tested are not well-known at all. I have checked the source code from Bitwarden and ended up in the AutoFillService implementation. I have been looking for events that are being fired, but can't really figure it out. What am I missing?
  4. How to do the password managers auto fill username, password in form? This post once again refers to Bitwarden's source code and it's about knowing where to fill in the values. Since I only work with a specific amount of sites, these are hard coded and that's not the issue I'm facing.

Thanks in advance! :-)

Kr Jonas

Jonas Vdr
  • 11
  • 2
  • Usually, sites written using a framework will ignore changes to `value` if no `change` event is triggered https://stackoverflow.com/questions/16013024/detect-programmatic-changes-on-input-type-text – Konrad Feb 05 '23 at 21:35
  • You can try replacing the button click with a form submit directly. I.e. `document.querySelector('form').submit();` – blurfus Feb 05 '23 at 22:00
  • Hm, I've tried dispatching the "change" event as said in the answers on the post you linked, but it still thinks no e-mail has been put in. The events I'm firing in my code are blur, change and input. I've just checked using firefox dev edition. The only events that show up are "invalid" and "onChange". I've tried firing change and onChange using a custom event and a normal event, but that didn't work either. Strange.. – Jonas Vdr Feb 05 '23 at 22:01
  • @blurfus I tried that, but it just reloads the page. So I tried firing the 'submit' event on the form, and that gives the same error. – Jonas Vdr Feb 05 '23 at 22:03
  • Try execCommand, [example](/a/57900849). – wOxxOm Feb 06 '23 at 06:55

0 Answers0