mirror of
https://github.com/denoland/deno.git
synced 2024-11-15 16:43:44 -05:00
24 lines
667 B
JavaScript
24 lines
667 B
JavaScript
|
self.onmessage = (evt) => {
|
||
|
console.log("Target from self.onmessage:", String(evt.target));
|
||
|
};
|
||
|
|
||
|
self.addEventListener("message", (evt) => {
|
||
|
console.log("Target from message event listener:", String(evt.target));
|
||
|
|
||
|
// Throw an error here so the global's error event will fire.
|
||
|
throw new Error("Some error message");
|
||
|
});
|
||
|
|
||
|
self.onerror = (...args) => {
|
||
|
console.log("Arguments from self.onerror:", args);
|
||
|
return true;
|
||
|
};
|
||
|
|
||
|
self.addEventListener("error", (evt) => {
|
||
|
// Returning true from self.onerror means that subsequent event listeners
|
||
|
// should see the event as canceled.
|
||
|
console.log("Is event canceled?:", evt.defaultPrevented);
|
||
|
|
||
|
self.close();
|
||
|
});
|