Closed Bug 969787 Opened 11 years ago Closed 1 year ago

onbeforeunload still allowed to "alert()" in some cases

Categories

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

27 Branch
x86
Windows XP
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: lbried, Unassigned)

References

()

Details

(Keywords: testcase)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Android; Tablet; rv:27.0) Gecko/27.0 Firefox/27.0 (Nightly/Aurora) Build ID: 20140128135901 Steps to reproduce: Seen on Firefox 27 on Windows Xp : if you press F5, the onunload event is not fired. It works on Firefox <= 26 Actual results: onunload event is not fired Expected results: onunload event must be fired
Component: Untriaged → Event Handling
Product: Firefox → Core
OS: Android → Windows XP
Hardware: Other → x86
Component: Event Handling → DOM: Events
Oops, probably shouldn't have moved this to another component.
Component: DOM: Events → Event Handling
Can't reproduce with a trivial testcase http://mozilla.pettay.fi/moztests/unload.html Loïc, this needs testcase.
This is my test case : http://lbried.free.fr/testcase.php Code : <!DOCTYPE html> <html> <head> <title>Firefox 27 onunload bug test case</title> </head> <body onunload="alert('onunload ok')"> Now, press F5 expecting onunload event to be fired ! </body> </html> It seems that it doesn't work on Firefox 27 Android too, and Firefox 26 on ubuntu 12.04 (32 bits)
(In reply to Loïc Bried from comment #3) > This is my test case : http://lbried.free.fr/testcase.php > > Code : > <!DOCTYPE html> > <html> > <head> > <title>Firefox 27 onunload bug test case</title> > </head> > <body onunload="alert('onunload ok')"> > Now, press F5 expecting onunload event to be fired ! > </body> > </html> > > It seems that it doesn't work on Firefox 27 Android too, and Firefox 26 on > ubuntu 12.04 (32 bits) alerts aren't allowed in unload(), see https://bugzilla.mozilla.org/show_bug.cgi?id=391834
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
(In reply to :Gijs Kruitbosch from comment #4) > (In reply to Loïc Bried from comment #3) > > This is my test case : http://lbried.free.fr/testcase.php > > > > Code : > > <!DOCTYPE html> > > <html> > > <head> > > <title>Firefox 27 onunload bug test case</title> > > </head> > > <body onunload="alert('onunload ok')"> > > Now, press F5 expecting onunload event to be fired ! > > </body> > > </html> > > > > It seems that it doesn't work on Firefox 27 Android too, and Firefox 26 on > > ubuntu 12.04 (32 bits) > > alerts aren't allowed in unload(), see > https://bugzilla.mozilla.org/show_bug.cgi?id=391834 (note that if you open the browser console on that testcase, you do get a bunch of NS_ERROR_NOT_AVAILABLE messages from the unload handler, showing that the method gets called fine - it's the alert that's the problem)
(In reply to :Gijs Kruitbosch from comment #4) > (In reply to Loïc Bried from comment #3) > > This is my test case : http://lbried.free.fr/testcase.php > > > > Code : > > <!DOCTYPE html> > > <html> > > <head> > > <title>Firefox 27 onunload bug test case</title> > > </head> > > <body onunload="alert('onunload ok')"> > > Now, press F5 expecting onunload event to be fired ! > > </body> > > </html> > > > > It seems that it doesn't work on Firefox 27 Android too, and Firefox 26 on > > ubuntu 12.04 (32 bits) > > alerts aren't allowed in unload(), see > https://bugzilla.mozilla.org/show_bug.cgi?id=391834 And as to why it used to work and is now fixed, see bug 856977.
I'm sorry : my real life code was so complex that I thinked it was the onunload event who was buggy, whereas it is onbeforeunload !!! I extracted what is buggy from complex code and obtained this new case test : http://lbried.free.fr/testcase2.php I can confirm that in FF <= 26, both F5 and click on link show "alert" placed in onbeforeunload. I understanded that "alert" in such event was disapproved, but in FF27 I can obtain it, not by F5 (NS_ERROR_NOT_AVAILABLE) as expected now, but clickink on link does it ! Code: <!DOCTYPE html> <html> <head> <title>Firefox 27 onbeforeunload bug test case</title> <script> function doReload() { document.location.href = document.location.href; return false; } </script> </head> <body onbeforeunload="alert('it\'s me, onbeforeunload !')"> If you press F5 no "alert" happens, but if you click <a href="#" onclick="return doReload()">this doReload link</a>, "alert" happens ! </body> </html>
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
Summary: onunload event not fired on reload since 27 version → Since 27 version, onbeforeunload event may sometimes show "alert()" or not
Status: UNCONFIRMED → NEW
Component: Event Handling → DOM
Ever confirmed: true
Summary: Since 27 version, onbeforeunload event may sometimes show "alert()" or not → onbeforeunload still allowed to "alert()" in some cases
Blocks: 856977, 391834
Attached file Reporter's testcase
I firmly believe its wrong to remove the ability to alert users to the possibility of loosing work if the close the browser or move to another page. Why was this removed in the first place, there is an argument for people abusing it but for every one developer abusing it there is a case for it in a real world environment.
(In reply to Chris from comment #9) > I firmly believe its wrong to remove the ability to alert users to the > possibility of loosing work if the close the browser or move to another > page. Why was this removed in the first place, there is an argument for > people abusing it but for every one developer abusing it there is a case for > it in a real world environment. Using alert() from within onbeforeunload isn't useful. If onbeforeunload returns a non-falsy value, we alert the user to the possibility of losing work. The negatives of the abuses for onbeforeunload are vastly bigger than those for proper uses, unfortunately. There are many cases where it's being abused to the point of extorting victims financially (see the dupes for bug 636374 and bug 616853). I agree that in an ideal world, that wouldn't be the tradeoff we'd have to make, but sadly we don't live in an ideal world.
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: normal → S3

This appears to work correctly in more recent versions of Firefox.

Status: NEW → RESOLVED
Closed: 11 years ago1 year ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: