Closed Bug 1658111 Opened 4 years ago Closed 10 months ago

window.open during window.beforeunload

Categories

(Core :: DOM: Core & HTML, defect, P3)

79 Branch
defect

Tracking

()

RESOLVED DUPLICATE of bug 1842992

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:

  1. 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>
  1. Disabled popup blocker
  2. 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.

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.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core

Related to bug 1434872?

Flags: needinfo?(hskupin)

(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.

Flags: needinfo?(hskupin) → needinfo?(bugs)

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.

Flags: needinfo?(bugs)
Severity: -- → S4
Priority: -- → P3
Status: UNCONFIRMED → RESOLVED
Closed: 10 months ago
Duplicate of bug: 1842992
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.