Closed Bug 512157 Opened 14 years ago Closed 13 years ago

Web worker onerror event object has blank message property

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 557346

People

(Reporter: webkit, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13

When an error occurs in a web worker script, the onerror event handler in the main page is called and the event object correctly contains a message property, a lineno property, and a filename property. The only problem is that the message property isn't filled in (it's always an empty string).

//in page
var worker = new Worker("worker.js");
worker.onerror = fucntion(event){
    alert("[" + event.message + "]");  //always empty string
};
worker.postMessage("start");

//in worker.js
self.onmessage = function(event){
    throw new Error("Something bad happened.");
};


Reproducible: Always

Steps to Reproduce:
1. Run above code
Actual Results:  
The alert displays "[]".

Expected Results:  
The alert displays "[Something bad happened.]"
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
It seems it depends what is thrown:

//in worker.js (FF 3.6.3 on Win7)

1) throw new Error("Something bad happened."); –> handler's event.message is ""
2) throw "something" –>  "something"
3) throw something_undefined –>  "something_undefined is not defined"
4) throw new MyObjectWith_toString("something") –>  "uncaught exception: something"
5) throw new MyObjectWithout_toString("something") –>  "uncaught exception: [object Object]"

where MyObjectWith_toString is a custom object with a toString() method.

Chrome (5.0) prepends the message with "Uncaught : ", so

1) "Uncaught Error: Something bad happened."
2) "Uncaught something"
3) "Uncaught ReferenceError: something_undefined is not defined"
4) "Uncaught something"
5) "Uncaught #"
hmmm... changes in FF 3.6.4 (win 7)

1) throw new Error('Something bad happened.'); –> "Something bad happened."  (FIXED!)
2) throw 'something' –>  'uncaught exception: something'  (SAME))
3) throw something_undefined –> == 'something_undefined is not defined' (SAME)
4) throw new MyObjectWith_toString('something') –> == 'uncaught exception: [object Object]' (REGRESS!)
5) throw new MyObjectWithout_toString('something') –> == 'uncaught exception: [object Object]' (SAME)
in Comment 1: #5 for chrome should read:

5) "Uncaught #<a MyObjectWithout_toString>"
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.