<?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>35302</bug_id>
          
          <creation_ts>2010-02-23 09:48:14 -0800</creation_ts>
          <short_desc>Worker error events do not have their message, filename, and lineno fields properly set</short_desc>
          <delta_ts>2011-11-14 15:27:27 -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>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</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="Andrew Wilson">atwilson</reporter>
          <assigned_to name="David Levin">levin</assigned_to>
          <cc>ap</cc>
    
    <cc>caseq</cc>
    
    <cc>chocoros</cc>
    
    <cc>dimich</cc>
    
    <cc>jianli</cc>
    
    <cc>levin</cc>
    
    <cc>omerkling</cc>
    
    <cc>yurys</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>192991</commentid>
    <comment_count>0</comment_count>
    <who name="Andrew Wilson">atwilson</who>
    <bug_when>2010-02-23 09:48:14 -0800</bug_when>
    <thetext>If you get an error from trying to load a non-existent script, the resulting ErrorEvent does not have its message, filename, or lineno fields set - I expected that at least the message field would be set.

Fail case: put this in a file and load it up in a browser - note that there&apos;s no message field, which makes it hard for developers to figure out why their worker script isn&apos;t loading.

&lt;body&gt;
&lt;script&gt;
  var worker = new Worker(&quot;foobar.js&quot;);
  worker.onerror = function(event) {
    var a = &quot;&quot;;
    for (x in event) {
      a += x + &quot;: &quot; + event[x] + &quot;\n&quot;;
    }
    alert(a);
  }
&lt;/script&gt;
&lt;/body&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>421349</commentid>
    <comment_count>1</comment_count>
      <attachid>97306</attachid>
    <who name="Owen Merkling">omerkling</who>
    <bug_when>2011-06-15 09:11:44 -0700</bug_when>
    <thetext>Created attachment 97306
SharedWorker or Worker js to demonstrate ErrorEvent bug</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>421352</commentid>
    <comment_count>2</comment_count>
    <who name="Owen Merkling">omerkling</who>
    <bug_when>2011-06-15 09:14:08 -0700</bug_when>
    <thetext>ErrorEvents created inside the WorkerGlobal scope also do not have their properties defined.  It appears that instead the paramater passed to onerror is the message itself, not an ErrorEvent.
Attached files that demonstrate this issue.


Expected output to console from running errors.html:
Message recieved from worker1: Uncaught Error: Test Error (or similar message)
Message recieved from worker2:  Uncaught Error: Test Error (or similar message)
Uncaught Error: Test Error


Actual:
Message recieved from worker1: No Error Message:Uncaught Error: Test Error
Message recieved from worker2: No Error Message:Uncaught Error: Test Error
Uncaught Error: Test Error


The &apos;No Error Message&apos; indicates that error.message was undefined, and &apos;Uncaught Error: Test Error&apos; was the string value of error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>421353</commentid>
    <comment_count>3</comment_count>
      <attachid>97307</attachid>
    <who name="Owen Merkling">omerkling</who>
    <bug_when>2011-06-15 09:14:31 -0700</bug_when>
    <thetext>Created attachment 97307
Page to demonstrate worker ErrorEvent problems</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>421708</commentid>
    <comment_count>4</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2011-06-15 19:26:18 -0700</bug_when>
    <thetext>Two issues:
1. The onerror is fired for both Workers and Window in the same was (using JSErrorHandler).  For Window it should give three arguements: Message, URL, Line Number.  For a Web Worker, I think it should be giving a ErrorEvent. Firefox gives the ErrorEvent and the current situation results in people having to write ugly code to detect the type of the first argument (like this http://cggallant.blogspot.com/2010/08/deeper-look-at-html-5-web-workers.html).

2. The 2nd and 3rd parameter are not set. (The URL is typically undefined and the line number is 0.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>421719</commentid>
    <comment_count>5</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2011-06-15 19:48:35 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; Two issues:
&gt; 1. The onerror is fired for both Workers and Window in the same was (using JSErrorHandler).  For Window it should give three arguements: Message, URL, Line Number.  For a Web Worker, I think it should be giving a ErrorEvent. Firefox gives the ErrorEvent and the current situation results in people having to write ugly code to detect the type of the first argument (like this http://cggallant.blogspot.com/2010/08/deeper-look-at-html-5-web-workers.html).


Ok, Firefox is simply wrong and perhaps the spec should be made more clear but WebKit is behaving correctly with respect to #1 (and the examples in this bug are incorrect actually).

See https://bugs.webkit.org/show_bug.cgi?id=36375#c6


&gt; 
&gt; 2. The 2nd and 3rd parameter are not set. (The URL is typically undefined and the line number is 0.)

This one is still an issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>421729</commentid>
    <comment_count>6</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2011-06-15 20:29:56 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; Ok, Firefox is simply wrong and perhaps the spec should be made more clear but WebKit is behaving correctly with respect to #1 (and the examples in this bug are incorrect actually).

Just verified that Opera also does what Safari does (except that it sets the url and line number correctly), so Firefox seems to be in the minority.

I filed https://bugzilla.mozilla.org/show_bug.cgi?id=664650 for Firefox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422809</commentid>
    <comment_count>7</comment_count>
    <who name="David Levin">levin</who>
    <bug_when>2011-06-17 12:03:14 -0700</bug_when>
    <thetext>#2 works in v8 but not with JavaScriptCore, but it turns out to be a generic problem with using throw, so I filed https://bugs.webkit.org/show_bug.cgi?id=62897.

Overall this bug is based on the onerror getting an ErrorEvent which isn&apos;t right. The spec has been clarified on this point.

I filed bug https://bugs.webkit.org/show_bug.cgi?id=62898 about expanding test coverage for onerror.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>97306</attachid>
            <date>2011-06-15 09:11:44 -0700</date>
            <delta_ts>2011-06-15 09:11:44 -0700</delta_ts>
            <desc>SharedWorker or Worker js to demonstrate ErrorEvent bug</desc>
            <filename>error-worker.js</filename>
            <type>application/javascript</type>
            <size>307</size>
            <attacher name="Owen Merkling">omerkling</attacher>
            
              <data encoding="base64">dmFyIG1zZyA9ICJObyBlcnJvciI7CnZhciBwb3J0ID0gc2VsZjsKCnNlbGYub25lcnJvciA9IGZ1
bmN0aW9uKGVycm9yRXZlbnQpIHsKICBtc2cgPSBlcnJvckV2ZW50Lm1lc3NhZ2UgfHwgIk5vIEVy
cm9yIE1lc3NhZ2U6IiArIGVycm9yRXZlbnQ7IAogIHBvcnQucG9zdE1lc3NhZ2UobXNnKTsKfQoK
c2VsZi5vbmNvbm5lY3QgPSBmdW5jdGlvbihldmVudCkgewogIHBvcnQgPSBldmVudC5wb3J0c1sw
XTsKfQoKc2V0VGltZW91dCgKICBmdW5jdGlvbigpIHsKICAgIHRocm93IG5ldyBFcnJvcigiVGVz
dCBFcnJvciIpOwogIH0sCiAgMCk7Cg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>97307</attachid>
            <date>2011-06-15 09:14:31 -0700</date>
            <delta_ts>2011-06-15 09:14:31 -0700</delta_ts>
            <desc>Page to demonstrate worker ErrorEvent problems</desc>
            <filename>errors.html</filename>
            <type>text/html</type>
            <size>409</size>
            <attacher name="Owen Merkling">omerkling</attacher>
            
              <data encoding="base64">PEhUTUw+CjxCT0RZPgo8c2NyaXB0IHR5cGU9InRleHQvamF2YXNjcmlwdCIgbGFuZ3VhZ2U9Imph
dmFzY3JpcHQiPgogdmFyIHdvcmtlcjEgPSBuZXcgU2hhcmVkV29ya2VyKCJlcnJvci13b3JrZXIu
anMiKTsKIAogd29ya2VyMS5wb3J0Lm9ubWVzc2FnZSA9IGZ1bmN0aW9uKCl7CiAgIGNvbnNvbGUu
bG9nKCJNZXNzYWdlIHJlY2lldmVkIGZyb20gd29ya2VyMTogIiArIGV2ZW50LmRhdGEpOwogfSAg
CiAgCiB2YXIgd29ya2VyMiA9IG5ldyBXb3JrZXIoImVycm9yLXdvcmtlci5qcyIpOwogIAogd29y
a2VyMi5vbm1lc3NhZ2UgPSBmdW5jdGlvbigpewogICBjb25zb2xlLmxvZygiTWVzc2FnZSByZWNp
ZXZlZCBmcm9tIHdvcmtlcjI6ICIgKyBldmVudC5kYXRhKTsKIH0KIAo8L3NjcmlwdD4KPC9CT0RZ
Pgo8L0hUTUw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>