From 69de2b91fdfe6d6ccf08dd1ab4cef75e2a1d1f74 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 12 Jul 2019 14:35:39 +0200 Subject: [PATCH] HTML: ensure serializing SharedArrayBuffer throws without COOP+COEP For https://github.com/whatwg/html/pull/4734. --- .../no-coop-coep.https.any.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/no-coop-coep.https.any.js 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"); +}