summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/resources/shared-worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/fenced-frame/resources/shared-worker.js')
-rw-r--r--testing/web-platform/tests/fenced-frame/resources/shared-worker.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fenced-frame/resources/shared-worker.js b/testing/web-platform/tests/fenced-frame/resources/shared-worker.js
new file mode 100644
index 0000000000..ac59fe6498
--- /dev/null
+++ b/testing/web-platform/tests/fenced-frame/resources/shared-worker.js
@@ -0,0 +1,14 @@
+// This is loaded as a SharedWorker in a WPT. When postMessaged to, forwards
+// that message to all registered ports through a postMessage call.
+const ports = [];
+
+onconnect = function (event) {
+ const port = event.ports[0];
+ ports.push(port);
+
+ port.onmessage = async function(e) {
+ ports.forEach(curPort => {
+ curPort.postMessage(e.data);
+ });
+ }
+}