-
Notifications
You must be signed in to change notification settings - Fork 3.1k
onbeforeunload return value handling is broken #2297
Description
If the event type is beforeunload
...
If the return value is null, then cancel the event.
which means that this testcase:
onbeforeunload = function() {};
should cancel the event, and hence lead to a beforeunload prompt. That's not how browsers actually behave.
The way Gecko behaves, based on code inspection, is that the "cancel the event" steps happen only if the return vaue is NOT null (and also if the event is an actual BeforeUnloadEvent, for what it's worth).
When this is fixed, please fix the html/webappapis/scripting/events/event-handler-processing-algorithm.html test in web platform tests, which was written based on the current spec text and fails in every browser I've tried it in.
I should note, that based on the results of that test and the behavior of browsers on this testcase:
onbeforeunload = function() {
return "";
}
(which leads to a beforeunload prompt in Firefox, Chrome, and Safari) it sounds like the Gecko behavior of only doing special things here for actual BeforeUnloadEvent instances is not so Gecko-specific.