Open Bug 981574 Opened 10 years ago Updated 2 years ago

onbeforeunload race condition: pressing reload quickly can cause reload despite pressing "Stay on this page"

Categories

(Firefox :: Tabbed Browser, defect)

27 Branch
x86_64
All
defect

Tracking

()

People

(Reporter: hapass, Unassigned)

Details

(Whiteboard: [bugday-20140317])

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36

Steps to reproduce:

1. Setup a site, that is subscribing to onbeforeunload event.

code example:

window.onbeforeunload = function (e) {
    var e = e || window.event;
    //IE & Firefox
    if (e) {
        e.returnValue = 'Your information has not been saved yet. If you leave now, the information might be lost.';
    }
    // For Safari
    return 'Your information has not been saved yet. If you leave now, the information might be lost.';
};

2. Open your website.
3. Hold F5 button (reloads the page repeatedly).
Note: the dialog appears, that is ensuring the user wants to leave the page
4. Press "stay on this page button" repeatedly. (while holding F5 button)
Note: after a while the page starts reloading
5. Press "stay on this page" button one more time.

P.S.
You can find more information about the bug here:
http://stackoverflow.com/questions/22297228/firefox-reloads-page-even-though-i-press-stay-on-this-page-button

You can find swf video file of me reproducing the bug in the attachment. (play it in the browser)

Firefox version: 27.0.1


Actual results:

The page is successfully reloaded.


Expected results:

The page stays as it is.
Could you attach here a usable testcase that does not require Flash, please?
Component: Untriaged → Event Handling
Keywords: testcase-wanted
Product: Firefox → Core
Summary: Firefox reloads page when I'am using onbeforeunload event, even though I press “stay on this page” button in the dialog. → Firefox reloads page when I'm using onbeforeunload event and pressing reload many times, even though I press “stay on this page” button in the dialog. (race condition?)
Whiteboard: [bugday-20140317]
Never mind: just paste the code from comment #0 into Scratchpad (Shift+F4).
Keywords: testcase-wanted
Summary: Firefox reloads page when I'm using onbeforeunload event and pressing reload many times, even though I press “stay on this page” button in the dialog. (race condition?) → onbeforeunload race condition: pressing reload quickly can cause reload despite pressing "Stay on this page"
(In reply to [:Aleksej] from comment #2)
> Never mind: just paste the code from comment #0 into Scratchpad (Shift+F4).

(on a page whose reloading would be noticable)
Status: UNCONFIRMED → NEW
Component: Event Handling → Tabbed Browser
Ever confirmed: true
OS: Windows 7 → All
Product: Core → Firefox
(In reply to [:Aleksej] from comment #3)
> (In reply to [:Aleksej] from comment #2)
> > Never mind: just paste the code from comment #0 into Scratchpad (Shift+F4).
> 
> (on a page whose reloading would be noticable)

Did I understand correctly, that you've been able to reproduce this bug and don't need help anymore? If not, I am ready to help, although I didn't quite understand what do you mean by

> Could you attach here a usable testcase that does not require Flash, please?

Flash is not required to reproduce this bug. I've attached a video of me reproducing the bug that requires flash to see it.
I can reproduce it, but I had to use Scratchpad to execute the code on an arbitrary page.  At grooveshark.com mentioned at the other page, a Flash warning interfered (at least distracting).
(In reply to [:Aleksej] from comment #5)
> I can reproduce it, but I had to use Scratchpad to execute the code on an
> arbitrary page.  At grooveshark.com mentioned at the other page, a Flash
> warning interfered (at least distracting).

Ok, I got it now. You can also use jsfiddle.net to reproduce this bug. No Flash required there :)

1. Go to jsfiddle.net
2. Type in ANY code in the "javascript" textarea.
3. Hold F5 and press stay on this page repeatedly.
Note: the page is reloaded.

Also! Note that after the page is reloaded you cannot type anything in the text areas.
Flags: firefox-backlog?
I agree that this is a bug but it seems like a very artificial one to me. How in the world is an average user supposed to hit this? Are there any other *sane* steps to reproduce this?
Flags: firefox-backlog? → firefox-backlog-
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: