Firefox Add-On: Browser Button Quits Working In Tab after Pop-Up Window Is Dismissed

Steps to reproduce:

  1. Install the Test Add-On (download, rename .xpi to .zip, unzip, and inspect first if you don't trust me).
  2. Note the addition of a square blue button in your browser chrome.
  3. Click the button and note the JavaScript alert.
  4. Click this link to open a pop-up window to about:blank.
  5. Note the about:blank pop-up. Don't close it.
  6. Come back to this window and click the browser button again to see the same JavaScript alert.
  7. Close the pop-up.
  8. Click the browser button again and note that the JavaScript alert does not appear.
  9. Reload the page, try the browser button again, and note that the alert does not appear.
  10. Click this link to load MDN in your active tab and try the browser button again. Note that the alert does not appear.
  11. Open a new browser tab (or change to an existing tab) and return to this one.
  12. Click the browser button again and note that the JavaScript alert appears.