summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/third_party/websockets/experiments/authentication/cookie_iframe.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/tools/third_party/websockets/experiments/authentication/cookie_iframe.js')
-rw-r--r--testing/web-platform/tests/tools/third_party/websockets/experiments/authentication/cookie_iframe.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/third_party/websockets/experiments/authentication/cookie_iframe.js b/testing/web-platform/tests/tools/third_party/websockets/experiments/authentication/cookie_iframe.js
new file mode 100644
index 0000000000..2d2e692e8d
--- /dev/null
+++ b/testing/web-platform/tests/tools/third_party/websockets/experiments/authentication/cookie_iframe.js
@@ -0,0 +1,9 @@
+// receive token from the parent window, set cookie and notify parent
+window.addEventListener("message", ({ origin, data }) => {
+ if (origin !== "http://localhost:8000") {
+ return;
+ }
+
+ document.cookie = `token=${data}; SameSite=Strict`;
+ window.parent.postMessage("", "http://localhost:8000");
+});