summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/sharedworker-failure.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/sharedworker-failure.js')
-rw-r--r--testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/sharedworker-failure.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/sharedworker-failure.js b/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/sharedworker-failure.js
new file mode 100644
index 0000000000..8472318abd
--- /dev/null
+++ b/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/sharedworker-failure.js
@@ -0,0 +1,18 @@
+let state = "send-sw-failure"
+onconnect = initialE => {
+ let port = initialE.source;
+ port.postMessage(state)
+ port.onmessage = e => {
+ if(state === "" && e.data === "send-window-failure") {
+ port.postMessage(new SharedArrayBuffer())
+ } else {
+ port.postMessage("failure")
+ }
+ }
+ port.onmessageerror = e => {
+ if(state === "send-sw-failure") {
+ port.postMessage("send-sw-failure-success")
+ state = ""
+ }
+ }
+}