RESOLVED INVALID 35302
Worker error events do not have their message, filename, and lineno fields properly set
https://bugs.webkit.org/show_bug.cgi?id=35302
Summary Worker error events do not have their message, filename, and lineno fields pr...
Andrew Wilson
Reported 2010-02-23 09:48:14 PST
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's no message field, which makes it hard for developers to figure out why their worker script isn't loading. <body> <script> var worker = new Worker("foobar.js"); worker.onerror = function(event) { var a = ""; for (x in event) { a += x + ": " + event[x] + "\n"; } alert(a); } </script> </body>
Attachments
SharedWorker or Worker js to demonstrate ErrorEvent bug (307 bytes, application/javascript)
2011-06-15 09:11 PDT, Owen Merkling
no flags
Page to demonstrate worker ErrorEvent problems (409 bytes, text/html)
2011-06-15 09:14 PDT, Owen Merkling
no flags
Owen Merkling
Comment 1 2011-06-15 09:11:44 PDT
Created attachment 97306 [details] SharedWorker or Worker js to demonstrate ErrorEvent bug
Owen Merkling
Comment 2 2011-06-15 09:14:08 PDT
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 'No Error Message' indicates that error.message was undefined, and 'Uncaught Error: Test Error' was the string value of error.
Owen Merkling
Comment 3 2011-06-15 09:14:31 PDT
Created attachment 97307 [details] Page to demonstrate worker ErrorEvent problems
David Levin
Comment 4 2011-06-15 19:26:18 PDT
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.)
David Levin
Comment 5 2011-06-15 19:48:35 PDT
(In reply to comment #4) > 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). 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 > > 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.
David Levin
Comment 6 2011-06-15 20:29:56 PDT
(In reply to comment #5) > 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.
David Levin
Comment 7 2011-06-17 12:03:14 PDT
#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'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.
Note You need to log in before you can comment on or make changes to this bug.