🩹(addon) show fallback message when dialog cannot auto-close

The dialog window does not close itself on Outlook Desktop, which
opens links in a webview that behaves like a different browser.

Calling window.close() fails because, for security reasons, JS is
prevented from closing the window. The browser considers that the JS
script is not the one that opened the dialog.

The dialog also loses its reference to the opener due to the
redirection, so there is no way to message the parent to trigger a
close.

Keeping the dialog reference on the parent side does not help either:
since the opener is lost, the parent cannot call close on the dialog.

After investigation, go with a temporary solution that shows an
explicit message hinting the user to close the dialog manually if it
does not close automatically.
This commit is contained in:
lebaudantoine
2026-06-08 18:55:35 +02:00
committed by aleb_the_flash
parent e5184695bb
commit f777f2fdeb
2 changed files with 11 additions and 0 deletions
@@ -40,5 +40,8 @@
</svg>
</span>
</div>
<p id="close-msg" style="display: none; text-align: center; font-size: 13px; color: #666; margin-top: 16px;">
Si cette fenêtre ne se ferme pas toute seule, veuillez la fermer manuellement.
</p>
</body>
</html>
@@ -11,10 +11,18 @@ if (!transitToken) {
window.close();
} else {
exchangeSession(transitToken)
.then(() => {
document.querySelector(".spinner-container").style.display = "none";
document.querySelector("#close-msg").style.display = "block";
})
.catch((e) => {
console.error(`Error occured: ${e}`);
})
.finally(() => {
// NOTE: doesn't work with the desktop client — the browser considers
// this window wasn't opened by this script (it was opened externally),
// so it blocks window.close() for security reasons. The "#close-msg"
// shown above is the fallback for that case.g
window.close();
});
}