diff --git a/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/no-coop-coep.https.any.js b/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/no-coop-coep.https.any.js new file mode 100644 index 00000000000000..96276d747047fc --- /dev/null +++ b/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/no-coop-coep.https.any.js @@ -0,0 +1,18 @@ +test(() => { + const sab = new SharedArrayBuffer(); + const channel = new MessageChannel(); + assert_throws("DataCloneError", () => channel.port1.postMessage(sab)); +}, "SharedArrayBuffer over MessageChannel without COOP+COEP"); + +test(() => { + const sab = new SharedArrayBuffer(); + const channel = new BroadcastChannel("Is mir egal"); + assert_throws("DataCloneError", () => channel.postMessage(sab)); +}, "SharedArrayBuffer over BroadcastChannel without COOP+COEP"); + +if (self.GLOBAL.isWindow()) { + test(() => { + const sab = new SharedArrayBuffer(); + assert_throws("DataCloneError", () => self.postMessage(sab)); + }, "SharedArrayBuffer over postMessage() without COOP+COEP"); +}