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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>25522</bug_id>
          
          <creation_ts>2014-04-30 20:57:57 +0000</creation_ts>
          <short_desc>No need to special case onerror attribute event handler</short_desc>
          <delta_ts>2014-06-05 22:57:01 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#event-handler-attributes</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>erik.arvidsson</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>104855</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-04-30 20:57:57 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html
Multipage: http://www.whatwg.org/C#event-handler-attributes
Complete: http://www.whatwg.org/c#event-handler-attributes
Referrer: 

Comment:
No need to special case onerror event handler

Posted from: 2620:0:1003:1017:2e41:38ff:fea6:f2aa
User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1951.5 Safari/537.36</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104856</commentid>
    <comment_count>1</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2014-04-30 21:00:30 +0000</bug_when>
    <thetext>I don&apos;t think we need to add new warts to http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#getting-the-current-value-of-the-event-handler

window.onerror is pretty new to be consistently implemented in browsers and we (Blink &amp; WebKit) do not expose source, lineno, colno, nor error as arguments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104878</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-04-30 22:46:45 +0000</bug_when>
    <thetext>&gt; and we (Blink &amp; WebKit) do not expose source, lineno, colno, nor error as
&gt; arguments.

Uh....

&lt;script&gt;
  onerror = function(a, b, c, d, e, f) {
    document.write(Array.prototype.slice.call(arguments));
  }
  throw new Error(&quot;haha&quot;);
&lt;/script&gt;

shows

  Uncaught Error: haha,file:///Users/bzbarsky/test.html,5,9,Error: haha

for me in Blink.  It shows 

  Error: haha,file:///Users/bzbarsky/test.html,5

in Safari.  So both have the source location and line number.  Blink also has the column number and exception object.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104879</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-04-30 22:47:04 +0000</bug_when>
    <thetext>Oh, and the exception object is a common web author request here; Gecko recently added it because of that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104881</commentid>
    <comment_count>4</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2014-04-30 23:13:43 +0000</bug_when>
    <thetext>Sorry, if this wasn&apos;t clear. I&apos;m only talking about onerror as an attribute event handler.

http://jsbin.com/halilova/1/

&lt;!DOCTYPE html&gt;
&lt;body onerror=&quot;console.log(source, lineno, colno, error)&quot;&gt;
&lt;script&gt;
syntax error
&lt;/script&gt;

Chrome 35: does not add any of the above.

Firefox 31: adds source and lineno but not colno or error.

IE11: Does not invoke the handle.

(Don&apos;t have access to a Mac at the moment)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104884</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-04-30 23:56:28 +0000</bug_when>
    <thetext>I&apos;m somewhat opposed to there being a difference between the &quot;attribute event handler&quot; case and the function being assigned to .onerror case.  All that happens with the attribute is a function is compiled and then assigned, and they should behave identically.

Current Firefox nightlies show a column number and exception object in your example.  Safari 7.0.3 seems to not invoke the handler at all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104886</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-05-01 00:01:48 +0000</bug_when>
    <thetext>And in particular, consider this testcase:

&lt;body onerror=&quot;document.write(Array.prototype.slice.call(arguments));&quot;&gt;
&lt;script&gt;
  onerror = onerror;
  throw new Error(&quot;haha&quot;);
&lt;/script&gt;
&lt;/body&gt;

Blink has different behavior depending on whether the &quot;onerror = onerror&quot; line is there, which seems pretty weird.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104966</commentid>
    <comment_count>7</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-05-02 12:26:51 +0000</bug_when>
    <thetext>I agree with Boris here. I think it&apos;s good to be consistent between attribute event handler and IDL event handler.

If you don&apos;t like &lt;body onerror&gt; then it seems more sane to argue that it shouldn&apos;t reflect window.onerror at all. (But then that would affect document.body.onerror also I guess...)

In webdevdata data set 2013-09-01 102,000 pages I found one match for grep -Ei &quot;&lt;body\s+[^&gt;]*onerror\s*=[^&gt;]+&gt;&quot;:

http://www.lmt.lv/lv
&lt;body id=&quot;page-sakumlapa&quot; class=&quot;lv&quot; onerror=&quot;js_error_reporter(event, source, lineno);&quot;&gt;

so it&apos;s not high usage but it&apos;s not zero either.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107396</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-06-05 21:40:08 +0000</bug_when>
    <thetext>arv, are zcorpan and bz&apos;s comments sufficiently convincing for you here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107400</commentid>
    <comment_count>9</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2014-06-05 21:59:59 +0000</bug_when>
    <thetext>Yeah. bz has me convinced.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107405</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-06-05 22:57:01 +0000</bug_when>
    <thetext>Cool.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>