summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/unit/structured_clone_test.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/cli/tests/unit/structured_clone_test.ts b/cli/tests/unit/structured_clone_test.ts
index fdad0dba7..c60b38a8a 100644
--- a/cli/tests/unit/structured_clone_test.ts
+++ b/cli/tests/unit/structured_clone_test.ts
@@ -27,4 +27,27 @@ Deno.test("correct DataCloneError message", () => {
DOMException,
"Value not transferable",
);
+
+ const ab = new ArrayBuffer(1);
+ // detach ArrayBuffer
+ structuredClone(ab, { transfer: [ab] });
+ assertThrows(
+ () => {
+ structuredClone(ab, { transfer: [ab] });
+ },
+ DOMException,
+ "ArrayBuffer at index 0 is already detached",
+ );
+
+ const ab2 = new ArrayBuffer(0);
+ assertThrows(
+ () => {
+ structuredClone([ab2, ab], { transfer: [ab2, ab] });
+ },
+ DOMException,
+ "ArrayBuffer at index 1 is already detached",
+ );
+
+ // ab2 should not be detached after above failure
+ structuredClone(ab2, { transfer: [ab2] });
});