summaryrefslogtreecommitdiff
path: root/tests/unit_node/worker_threads_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_node/worker_threads_test.ts')
-rw-r--r--tests/unit_node/worker_threads_test.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/unit_node/worker_threads_test.ts b/tests/unit_node/worker_threads_test.ts
index bc451e33f..1ded9a591 100644
--- a/tests/unit_node/worker_threads_test.ts
+++ b/tests/unit_node/worker_threads_test.ts
@@ -218,3 +218,23 @@ Deno.test({
clearTimeout(timeout);
},
});
+
+Deno.test({
+ name: "[worker_threads] SharedArrayBuffer",
+ async fn() {
+ const sab = new SharedArrayBuffer(Uint8Array.BYTES_PER_ELEMENT);
+ const uint = new Uint8Array(sab);
+ const worker = new workerThreads.Worker(
+ new URL("./testdata/worker_threads2.mjs", import.meta.url),
+ {
+ workerData: { sharedArrayBuffer: sab },
+ },
+ );
+ worker.postMessage("Hello");
+ if ((await once(worker, "message"))[0] != "Hello") throw new Error();
+ await new Promise((resolve) => setTimeout(resolve, 100));
+ worker.terminate();
+ if (uint[0] != 1) throw new Error();
+ },
+ sanitizeResources: false,
+});