2020-01-17 18:43:53 -05:00
|
|
|
let thrown = false;
|
|
|
|
|
2020-01-29 12:54:23 -05:00
|
|
|
// TODO(bartlomieju): add test for throwing in web worker
|
|
|
|
if (self.name !== "jsWorker") {
|
|
|
|
throw Error(`Bad worker name: ${self.name}, expected jsWorker`);
|
|
|
|
}
|
|
|
|
|
2019-04-01 15:09:59 -04:00
|
|
|
onmessage = function(e) {
|
|
|
|
console.log(e.data);
|
|
|
|
|
2020-01-17 18:43:53 -05:00
|
|
|
if (thrown === false) {
|
|
|
|
thrown = true;
|
|
|
|
throw new SyntaxError("[test error]");
|
|
|
|
}
|
|
|
|
|
2019-04-01 15:09:59 -04:00
|
|
|
postMessage(e.data);
|
|
|
|
|
2020-01-29 12:54:23 -05:00
|
|
|
close();
|
2019-04-01 15:09:59 -04:00
|
|
|
};
|
2020-01-17 18:43:53 -05:00
|
|
|
|
|
|
|
onerror = function() {
|
|
|
|
console.log("called onerror in worker");
|
|
|
|
return false;
|
|
|
|
};
|