XMLHttpRequest problem in Firefox extension I'm developing

In your last code you are making a request outside any function (in the top level execution), so it’s executed when JavaScript file is processed.

Regardless I would change two things in your code.

  1. I would switch to asynchronous fetch API - it’s much easier to reason about and it makes the code easier to understand
  2. you should NEVER send sensitive information in the URL. You should send the password and e-mail as body or in the headers.