Detect and notify user when OAuth2 popup is blocked
The OAuth2 flow used by GMail (and probably others, soon enough) relies on a popup window. Some browsers are configured to block pop-ups. We should try and detect when that happens and tell the user something helpful (like: please allow this popup).
From javascript.info:
Most browsers block popups if they are called outside of user-triggered event handlers like onclick.
For example:
// popup blocked window.open('https://javascript.info'); // popup allowed button.onclick = () => { window.open('https://javascript.info'); };
The javascript to open the OAuth2 popup is an onclick event, and as such, the popup will most likely not be blocked by most browsers.
Here's a reference for the same type of issue on the facebook/react github
Well yes, it shouldn't be blocked. But we've had reports and seen cases where it was, because of nonstandard settings or security enhancing extensions.
Since the overlap between Mailpile users and users of security-enhancing extensions is relatively large, it makes sense to try and detect this state if possible.
Addendum: Thank you for the link! That looks like a useful resource for whoever decides to research this further.