window.open during window.beforeunload
Categories
(Core :: DOM: Core & HTML, defect, P3)
Tracking
()
People
(Reporter: dattasohom1, Unassigned)
Details
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0
Steps to reproduce:
- Created a page on a apache server with the following code
<script>window.addEventListener('beforeunload', function (e) {
var x = stayhere();
e.preventDefault();
e.returnValue = 'Don\'t go away.' + x;
});
function stayhere() {
window.open( 'http://localhost/index.php' );
return 1;
};
</script>
- Disabled popup blocker
- Opened the page and then tried closing the page.
Actual results:
The code creates a page that basically can't be closed. With the popup blocker disabled, every time the user attempts to close the page, a new page is created which takes the place of the old page.
Expected results:
beforeunload should prevent popups irrespective of whether the popup blocker is active. This seems to be what chrome does by default.
Reporter | ||
Comment 1•4 years ago
|
||
PS: Once you turn on popup blocker you are again able to close the page.
PS: This could be construed as a minor security risk as malicious sites may be able to use this to prevent their sites from being closed.
Updated•4 years ago
|
Comment 3•4 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #2)
Related to bug 1434872?
Maybe. We disabled the beforeunload
usage in Marionette by setting the dom.disable_beforeunload
preference to false. We could consider removing that if the underlying problem (if it's realy) is fixed.
Olli should be a good person to ask in how the behavior should be.
Comment 4•4 years ago
|
||
Well, if popup blocker is disabled, lots of annoying things can be done, like opening new window every now and then, and then those windows keep opening new windows and what not.
I'm not sure if Chrome's behavior is any better here.
Updated•4 years ago
|
Updated•10 months ago
|
Description
•