2022-01-07 22:09:52 -05:00
|
|
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
2021-02-04 17:18:32 -05:00
|
|
|
"use strict";
|
2020-07-19 13:49:44 -04:00
|
|
|
|
|
|
|
((window) => {
|
2020-09-16 16:22:43 -04:00
|
|
|
const core = window.Deno.core;
|
2021-07-03 10:58:08 -04:00
|
|
|
const {
|
|
|
|
Error,
|
2022-02-01 12:06:11 -05:00
|
|
|
ObjectPrototypeIsPrototypeOf,
|
2021-07-03 10:58:08 -04:00
|
|
|
StringPrototypeStartsWith,
|
|
|
|
String,
|
|
|
|
SymbolIterator,
|
2021-09-24 13:07:22 -04:00
|
|
|
SymbolToStringTag,
|
2021-07-03 10:58:08 -04:00
|
|
|
} = window.__bootstrap.primordials;
|
2021-06-22 10:30:16 -04:00
|
|
|
const webidl = window.__bootstrap.webidl;
|
2021-07-03 10:58:08 -04:00
|
|
|
const { URL } = window.__bootstrap.url;
|
2021-01-07 13:06:08 -05:00
|
|
|
const { getLocationHref } = window.__bootstrap.location;
|
2021-10-13 13:04:44 -04:00
|
|
|
const { serializePermissions } = window.__bootstrap.permissions;
|
|
|
|
const { log } = window.__bootstrap.util;
|
2021-10-08 03:53:31 -04:00
|
|
|
const { defineEventHandler } = window.__bootstrap.event;
|
2022-02-01 12:06:11 -05:00
|
|
|
const {
|
|
|
|
deserializeJsMessageData,
|
|
|
|
serializeJsMessageData,
|
|
|
|
MessagePortPrototype,
|
|
|
|
} = window.__bootstrap.messagePort;
|
2020-07-19 13:49:44 -04:00
|
|
|
|
|
|
|
function createWorker(
|
|
|
|
specifier,
|
|
|
|
hasSourceCode,
|
|
|
|
sourceCode,
|
|
|
|
useDenoNamespace,
|
2021-01-06 15:31:16 -05:00
|
|
|
permissions,
|
2020-07-19 13:49:44 -04:00
|
|
|
name,
|
2021-08-16 08:29:54 -04:00
|
|
|
workerType,
|
2020-07-19 13:49:44 -04:00
|
|
|
) {
|
2021-04-12 15:55:05 -04:00
|
|
|
return core.opSync("op_create_worker", {
|
2020-07-19 13:49:44 -04:00
|
|
|
hasSourceCode,
|
|
|
|
name,
|
2021-10-13 13:04:44 -04:00
|
|
|
permissions: serializePermissions(permissions),
|
2021-01-06 15:31:16 -05:00
|
|
|
sourceCode,
|
|
|
|
specifier,
|
2020-07-19 13:49:44 -04:00
|
|
|
useDenoNamespace,
|
2021-08-16 08:29:54 -04:00
|
|
|
workerType,
|
2020-07-19 13:49:44 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function hostTerminateWorker(id) {
|
2021-04-12 15:55:05 -04:00
|
|
|
core.opSync("op_host_terminate_worker", id);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function hostPostMessage(id, data) {
|
2021-04-12 15:55:05 -04:00
|
|
|
core.opSync("op_host_post_message", id, data);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
2021-06-22 10:30:16 -04:00
|
|
|
function hostRecvCtrl(id) {
|
|
|
|
return core.opAsync("op_host_recv_ctrl", id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function hostRecvMessage(id) {
|
|
|
|
return core.opAsync("op_host_recv_message", id);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
class Worker extends EventTarget {
|
|
|
|
#id = 0;
|
|
|
|
#name = "";
|
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.
The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.
The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.
The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 05:05:02 -04:00
|
|
|
|
|
|
|
// "RUNNING" | "CLOSED" | "TERMINATED"
|
|
|
|
// "TERMINATED" means that any controls or messages received will be
|
|
|
|
// discarded. "CLOSED" means that we have received a control
|
|
|
|
// indicating that the worker is no longer running, but there might
|
|
|
|
// still be messages left to receive.
|
|
|
|
#status = "RUNNING";
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2021-01-06 15:31:16 -05:00
|
|
|
constructor(specifier, options = {}) {
|
2020-07-19 13:49:44 -04:00
|
|
|
super();
|
2021-01-07 13:06:08 -05:00
|
|
|
specifier = String(specifier);
|
2021-01-06 15:31:16 -05:00
|
|
|
const {
|
2021-10-13 13:04:44 -04:00
|
|
|
deno,
|
|
|
|
name,
|
2021-01-06 15:31:16 -05:00
|
|
|
type = "classic",
|
|
|
|
} = options;
|
|
|
|
|
2021-10-13 13:04:44 -04:00
|
|
|
let namespace;
|
|
|
|
let permissions;
|
|
|
|
if (typeof deno == "object") {
|
|
|
|
namespace = deno.namespace ?? false;
|
|
|
|
permissions = deno.permissions ?? undefined;
|
2021-01-06 15:31:16 -05:00
|
|
|
} else {
|
2021-10-13 13:04:44 -04:00
|
|
|
// Assume `deno: boolean | undefined`.
|
|
|
|
// TODO(Soremwar)
|
|
|
|
// `deno: boolean` is kept for backwards compatibility with the previous
|
|
|
|
// worker options implementation. Remove for 2.0
|
|
|
|
namespace = !!deno;
|
|
|
|
permissions = undefined;
|
2021-01-06 15:31:16 -05:00
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2021-08-16 08:29:54 -04:00
|
|
|
const workerType = webidl.converters["WorkerType"](type);
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2021-01-07 13:06:08 -05:00
|
|
|
if (
|
2021-07-03 10:58:08 -04:00
|
|
|
StringPrototypeStartsWith(specifier, "./") ||
|
|
|
|
StringPrototypeStartsWith(specifier, "../") ||
|
2021-08-16 08:29:54 -04:00
|
|
|
StringPrototypeStartsWith(specifier, "/") || workerType === "classic"
|
2021-01-07 13:06:08 -05:00
|
|
|
) {
|
|
|
|
const baseUrl = getLocationHref();
|
|
|
|
if (baseUrl != null) {
|
|
|
|
specifier = new URL(specifier, baseUrl).href;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-16 08:29:54 -04:00
|
|
|
this.#name = name;
|
|
|
|
let hasSourceCode, sourceCode;
|
|
|
|
if (workerType === "classic") {
|
|
|
|
hasSourceCode = true;
|
|
|
|
sourceCode = `importScripts("#");`;
|
|
|
|
} else {
|
|
|
|
hasSourceCode = false;
|
|
|
|
sourceCode = "";
|
|
|
|
}
|
|
|
|
|
2021-04-05 12:40:24 -04:00
|
|
|
const id = createWorker(
|
2020-07-19 13:49:44 -04:00
|
|
|
specifier,
|
|
|
|
hasSourceCode,
|
|
|
|
sourceCode,
|
2021-10-13 13:04:44 -04:00
|
|
|
namespace,
|
|
|
|
permissions,
|
|
|
|
name,
|
2021-08-16 08:29:54 -04:00
|
|
|
workerType,
|
2020-07-19 13:49:44 -04:00
|
|
|
);
|
|
|
|
this.#id = id;
|
2021-06-22 10:30:16 -04:00
|
|
|
this.#pollControl();
|
|
|
|
this.#pollMessages();
|
2021-05-27 19:33:11 -04:00
|
|
|
}
|
2021-10-13 13:04:44 -04:00
|
|
|
|
2021-05-27 19:33:11 -04:00
|
|
|
#handleError(e) {
|
2020-07-19 13:49:44 -04:00
|
|
|
const event = new ErrorEvent("error", {
|
|
|
|
cancelable: true,
|
|
|
|
message: e.message,
|
|
|
|
lineno: e.lineNumber ? e.lineNumber + 1 : undefined,
|
|
|
|
colno: e.columnNumber ? e.columnNumber + 1 : undefined,
|
|
|
|
filename: e.fileName,
|
|
|
|
error: null,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.dispatchEvent(event);
|
2022-04-13 05:50:57 -04:00
|
|
|
// Don't bubble error event to window for loader errors (`!e.fileName`).
|
|
|
|
// TODO(nayeemrmn): Currently these are never bubbled because worker
|
|
|
|
// error event fields aren't populated correctly and `e.fileName` is
|
|
|
|
// always empty.
|
|
|
|
if (e.fileName && !event.defaultPrevented) {
|
|
|
|
window.dispatchEvent(event);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
2022-04-13 05:50:57 -04:00
|
|
|
return event.defaultPrevented;
|
2021-05-27 19:33:11 -04:00
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2021-06-22 10:30:16 -04:00
|
|
|
#pollControl = async () => {
|
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.
The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.
The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.
The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 05:05:02 -04:00
|
|
|
while (this.#status === "RUNNING") {
|
2021-06-22 10:30:16 -04:00
|
|
|
const [type, data] = await hostRecvCtrl(this.#id);
|
2020-07-19 13:49:44 -04:00
|
|
|
|
|
|
|
// If terminate was called then we ignore all messages
|
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.
The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.
The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.
The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 05:05:02 -04:00
|
|
|
if (this.#status === "TERMINATED") {
|
2020-07-19 13:49:44 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:09:09 -04:00
|
|
|
switch (type) {
|
|
|
|
case 1: { // TerminalError
|
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.
The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.
The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.
The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 05:05:02 -04:00
|
|
|
this.#status = "CLOSED";
|
2021-05-11 15:09:09 -04:00
|
|
|
} /* falls through */
|
|
|
|
case 2: { // Error
|
|
|
|
if (!this.#handleError(data)) {
|
2022-04-13 05:50:57 -04:00
|
|
|
throw new Error("Unhandled error in child worker.");
|
2020-10-20 00:05:42 -04:00
|
|
|
}
|
2021-05-11 15:09:09 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: { // Close
|
|
|
|
log(`Host got "close" message from worker: ${this.#name}`);
|
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.
The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.
The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.
The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 05:05:02 -04:00
|
|
|
this.#status = "CLOSED";
|
2021-05-11 15:09:09 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
throw new Error(`Unknown worker event: "${type}"`);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-06-22 10:30:16 -04:00
|
|
|
#pollMessages = async () => {
|
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.
The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.
The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.
The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 05:05:02 -04:00
|
|
|
while (this.#status !== "TERMINATED") {
|
2021-06-22 10:30:16 -04:00
|
|
|
const data = await hostRecvMessage(this.#id);
|
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.
The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.
The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.
The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 05:05:02 -04:00
|
|
|
if (this.#status === "TERMINATED" || data === null) {
|
|
|
|
return;
|
|
|
|
}
|
2021-08-25 07:48:53 -04:00
|
|
|
let message, transferables;
|
2021-06-22 10:30:16 -04:00
|
|
|
try {
|
|
|
|
const v = deserializeJsMessageData(data);
|
|
|
|
message = v[0];
|
2021-08-25 07:48:53 -04:00
|
|
|
transferables = v[1];
|
2021-06-22 10:30:16 -04:00
|
|
|
} catch (err) {
|
|
|
|
const event = new MessageEvent("messageerror", {
|
|
|
|
cancelable: false,
|
|
|
|
data: err,
|
|
|
|
});
|
|
|
|
this.dispatchEvent(event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const event = new MessageEvent("message", {
|
|
|
|
cancelable: false,
|
|
|
|
data: message,
|
2022-02-01 12:06:11 -05:00
|
|
|
ports: transferables.filter((t) =>
|
|
|
|
ObjectPrototypeIsPrototypeOf(MessagePortPrototype, t)
|
|
|
|
),
|
2021-06-22 10:30:16 -04:00
|
|
|
});
|
|
|
|
this.dispatchEvent(event);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
2021-06-22 10:30:16 -04:00
|
|
|
};
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2021-06-22 10:30:16 -04:00
|
|
|
postMessage(message, transferOrOptions = {}) {
|
|
|
|
const prefix = "Failed to execute 'postMessage' on 'MessagePort'";
|
|
|
|
webidl.requiredArguments(arguments.length, 1, { prefix });
|
|
|
|
message = webidl.converters.any(message);
|
|
|
|
let options;
|
|
|
|
if (
|
|
|
|
webidl.type(transferOrOptions) === "Object" &&
|
|
|
|
transferOrOptions !== undefined &&
|
2021-07-03 10:58:08 -04:00
|
|
|
transferOrOptions[SymbolIterator] !== undefined
|
2021-06-22 10:30:16 -04:00
|
|
|
) {
|
|
|
|
const transfer = webidl.converters["sequence<object>"](
|
|
|
|
transferOrOptions,
|
|
|
|
{ prefix, context: "Argument 2" },
|
|
|
|
);
|
|
|
|
options = { transfer };
|
|
|
|
} else {
|
2021-08-09 04:39:00 -04:00
|
|
|
options = webidl.converters.StructuredSerializeOptions(
|
|
|
|
transferOrOptions,
|
|
|
|
{
|
|
|
|
prefix,
|
|
|
|
context: "Argument 2",
|
|
|
|
},
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
2021-06-22 10:30:16 -04:00
|
|
|
const { transfer } = options;
|
|
|
|
const data = serializeJsMessageData(message, transfer);
|
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.
The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.
The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.
The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 05:05:02 -04:00
|
|
|
if (this.#status === "RUNNING") {
|
|
|
|
hostPostMessage(this.#id, data);
|
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
terminate() {
|
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.
The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.
The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.
The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 05:05:02 -04:00
|
|
|
if (this.#status !== "TERMINATED") {
|
|
|
|
this.#status = "TERMINATED";
|
2020-07-19 13:49:44 -04:00
|
|
|
hostTerminateWorker(this.#id);
|
|
|
|
}
|
|
|
|
}
|
2021-09-24 13:07:22 -04:00
|
|
|
|
|
|
|
[SymbolToStringTag] = "Worker";
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
2020-11-10 07:15:42 -05:00
|
|
|
defineEventHandler(Worker.prototype, "error");
|
|
|
|
defineEventHandler(Worker.prototype, "message");
|
|
|
|
defineEventHandler(Worker.prototype, "messageerror");
|
|
|
|
|
2021-08-16 08:29:54 -04:00
|
|
|
webidl.converters["WorkerType"] = webidl.createEnumConverter("WorkerType", [
|
|
|
|
"classic",
|
|
|
|
"module",
|
|
|
|
]);
|
|
|
|
|
2020-07-19 13:49:44 -04:00
|
|
|
window.__bootstrap.worker = {
|
|
|
|
Worker,
|
|
|
|
};
|
|
|
|
})(this);
|