blob: f0884cc1d26a3ac6bc942d9c22a194338329b03d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
const isSharedWorker =
"SharedWorkerGlobalScope" in self && self instanceof SharedWorkerGlobalScope;
function setMessageHandler(response) {
onmessage = e => {
e.ports[0].postMessage(response);
};
if (isSharedWorker) {
onconnect = e => {
e.ports[0].onmessage = onmessage;
};
}
}
setMessageHandler("handler-before-throw");
throw new Error("uncaught-exception");
// This should never be called because of the uncaught exception above.
setMessageHandler("handler-after-throw");
|