Bug 20135

Summary: onbeforeunload doesn't work when set with addEventListener
Product: WebKit Reporter: Ojan Vafai <ovafai>
Component: WebCore JavaScriptAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: ap, cdumez, dimich, kangax, laszlo.gombos, syoichi
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
testcase that works in IE/FF but fails in WebKit none

Ojan Vafai
Reported 2008-07-22 14:33:21 PDT
window.addEventListener('beforeunload', function(e) { (e || window.event).returnValue = "wot?"; return "wot?"; }, true); This should popup a dialog asking if I want to leave the page when I try to navigate away. In WebKit, it only seems to do so if I set the handler using window.onbeforeunload.
Attachments
testcase that works in IE/FF but fails in WebKit (439 bytes, text/html)
2008-07-22 14:34 PDT, Ojan Vafai
no flags
Ojan Vafai
Comment 1 2008-07-22 14:34:40 PDT
Created attachment 22434 [details] testcase that works in IE/FF but fails in WebKit You should see an onbeforeunload dialog, followed by an alert in the onunload handler. In WebKit, you only see the alert from the onunload handler.
Alexey Proskuryakov
Comment 2 2008-11-10 22:56:27 PST
Confirmed with r38249 on Mac OS X.
Dmitry Titov
Comment 3 2009-11-10 15:51:57 PST
This is fixed by the recent changes to EventTarget that unified addEventListeners and event attributes. Works with r 50777 on Mac OS X. It'd be good to have a test though.
Note You need to log in before you can comment on or make changes to this bug.