1 onconnect = function(event) {
2 event.ports[0].onmessage = function(evt) { handleMessage(evt, event.ports[0]); };
5 function handleMessage(event, port) {
6 if (event.data == "unhandledError") {
7 // Generate an unhandled error.
9 setTimeout(function() {
10 port.postMessage("SUCCESS: unhandled error generated");
12 generateError(); // Undefined function call
13 } else if (event.data == "handledError") {
14 onerror = function(message, url, lineno) {
15 port.postMessage("SUCCESS: error handled via onerror: " + message);
18 generateError(); // Undefined function call
20 port.postMessage("FAIL: Got unexpected message: " + event.data);