<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>20135</bug_id>
          
          <creation_ts>2008-07-22 14:33:21 -0700</creation_ts>
          <short_desc>onbeforeunload doesn&apos;t work when set with addEventListener</short_desc>
          <delta_ts>2017-02-19 18:39:37 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore JavaScript</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ojan Vafai">ovafai</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>dimich</cc>
    
    <cc>kangax</cc>
    
    <cc>laszlo.gombos</cc>
    
    <cc>syoichi</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>86679</commentid>
    <comment_count>0</comment_count>
    <who name="Ojan Vafai">ovafai</who>
    <bug_when>2008-07-22 14:33:21 -0700</bug_when>
    <thetext>window.addEventListener(&apos;beforeunload&apos;, function(e) {
  (e || window.event).returnValue = &quot;wot?&quot;;
  return &quot;wot?&quot;;
}, 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86680</commentid>
    <comment_count>1</comment_count>
      <attachid>22434</attachid>
    <who name="Ojan Vafai">ovafai</who>
    <bug_when>2008-07-22 14:34:40 -0700</bug_when>
    <thetext>Created attachment 22434
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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98266</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-11-10 22:56:27 -0800</bug_when>
    <thetext>Confirmed with r38249 on Mac OS X.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>162257</commentid>
    <comment_count>3</comment_count>
    <who name="Dmitry Titov">dimich</who>
    <bug_when>2009-11-10 15:51:57 -0800</bug_when>
    <thetext>This is fixed by the recent changes to EventTarget that unified addEventListeners and event attributes. Works with r 50777 on Mac OS X.
It&apos;d be good to have a test though.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>22434</attachid>
            <date>2008-07-22 14:34:40 -0700</date>
            <delta_ts>2008-07-22 14:34:40 -0700</delta_ts>
            <desc>testcase that works in IE/FF but fails in WebKit</desc>
            <filename>onbeforeunload.html</filename>
            <type>text/html</type>
            <size>439</size>
            <attacher name="Ojan Vafai">ovafai</attacher>
            
              <data encoding="base64">PGh0bWw+DQo8Ym9keT4NCjxzY3JpcHQ+DQpmdW5jdGlvbiBhZGRXaW5kb3dMaXN0ZW5lcihldmVu
dCwgaGFuZGxlcikgew0KICBpZiAod2luZG93LmFkZEV2ZW50TGlzdGVuZXIpIHsNCiAgICB3aW5k
b3cuYWRkRXZlbnRMaXN0ZW5lcihldmVudCwgaGFuZGxlciwgdHJ1ZSk7DQogIH0gZWxzZSB7DQog
ICAgd2luZG93LmF0dGFjaEV2ZW50KCJvbiIgKyBldmVudCwgaGFuZGxlcik7DQogIH0NCn0NCg0K
YWRkV2luZG93TGlzdGVuZXIoJ2JlZm9yZXVubG9hZCcsIGZ1bmN0aW9uKGUpIHsNCiAgKGUgfHwg
d2luZG93LmV2ZW50KS5yZXR1cm5WYWx1ZSA9ICJ3b3Q/IjsNCiAgcmV0dXJuICJ3b3Q/IjsNCn0p
Ow0KDQphZGRXaW5kb3dMaXN0ZW5lcigndW5sb2FkJywgZnVuY3Rpb24oZSkgew0KICBhbGVydCgn
Zm9vJyk7DQp9KTsNCjwvc2NyaXB0Pg0KPC9ib2R5Pg0KPC9odG1sPg==
</data>

          </attachment>
      

    </bug>

</bugzilla>