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)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: lbried, Unassigned)
References
()
Details
(Keywords: testcase)
Attachments
(1 file)
488 bytes,
text/html
|
Details |
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
Updated•11 years ago
|
Component: Untriaged → Event Handling
Product: Firefox → Core
Reporter | ||
Updated•11 years ago
|
OS: Android → Windows XP
Hardware: Other → x86
Updated•11 years ago
|
Component: Event Handling → DOM: Events
Comment 1•11 years ago
|
||
Oops, probably shouldn't have moved this to another component.
Component: DOM: Events → Event Handling
Comment 2•11 years ago
|
||
Can't reproduce with a trivial testcase http://mozilla.pettay.fi/moztests/unload.html
Loïc, this needs testcase.
Reporter | ||
Comment 3•11 years ago
|
||
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)
Comment 4•11 years ago
|
||
(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
Comment 5•11 years ago
|
||
(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)
Comment 6•11 years ago
|
||
(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.
Reporter | ||
Comment 7•11 years ago
|
||
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 → ---
Reporter | ||
Updated•11 years ago
|
Summary: onunload event not fired on reload since 27 version → Since 27 version, onbeforeunload event may sometimes show "alert()" or not
Updated•11 years ago
|
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
Updated•11 years ago
|
Comment 8•11 years ago
|
||
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.
Comment 10•11 years ago
|
||
(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.
Comment 11•7 years ago
|
||
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
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
Updated•2 years ago
|
Severity: normal → S3
Comment 12•1 year ago
|
||
This appears to work correctly in more recent versions of Firefox.
Status: NEW → RESOLVED
Closed: 11 years ago → 1 year ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•