Open Bug 1790044 Opened 2 years ago Updated 2 years ago

window:beforeunload gets fired on form submit

Categories

(Core :: DOM: Forms, defect)

Firefox 104
defect

Tracking

()

UNCONFIRMED

People

(Reporter: markusroettgermann, Unassigned)

Details

(Keywords: webcompat:needs-diagnosis)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Steps to reproduce:

create form <form>
....
<button type="submit"
...
</button>
...
</form>

Actual results:

A dialog shows up if i want to leave the page

Expected results:

Nothing. There should no unload event beeing fired on form submit

:markusroettgermann thanks for filing this bug, I'm removing security flag as this is not a security issue.

Submit event is supposed to reload the page (unless it's default processing is cancelled). Which in turn will unload current page. Perhaps I've misunderstood what your concern is, can you attach a POC please?

Group: firefox-core-security
Flags: needinfo?(markusroettgermann)

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Forms' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Forms
Product: Firefox → Core

Sorry for comming back late. I think Firefox is behaving correctly here and this is an Angular Issue. Since Angular is using his own ReactiveFormsModule for validating and sending data, default form behaviour like a window reload and setting query parameters have been succesfully supressed by the framework. Sadly im unable to track down when the angular behaviour started to change.

Also Chrome seems to ignore form default behaviour in angular context when Firefox does not. Sadly i couldnt determine how Chrome decides to do this. In my minimal reproduction repository Chrome also tries to reload, causing an unload event.

https://github.com/maro1993/firefox-unload-app/tree/master/src

Point i'm trying to make is that in our real application there are clear behaviour differences from Chrome and Firefox using basically the structure in the minimal reproduction repo. I'm sorry i couldnt pinpoint the exact issue and leave this to hint at an potential behaviour difference.

Flags: needinfo?(markusroettgermann)
Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.