diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index 6f5d22461df0..6e7ad627735c 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -310326,37 +310326,112 @@ {} ] ], - "wasm/resources/blank.html": [ - [ - {} - ] - ], - "wasm/resources/frame.html": [ - [ - {} - ] - ], - "wasm/resources/incrementer.wasm": [ - [ - {} - ] - ], "wasm/resources/load_wasm.js": [ [ {} ] ], - "wasm/resources/service-worker.js": [ + "wasm/serialization/incrementer.wasm": [ [ {} ] ], - "wasm/wasm_serialization_tests.js": [ + "wasm/serialization/resources/blank.html": [ [ {} ] ], - "wasm/wasm_serialization_worker.js": [ + "wasm/serialization/resources/broadcastchannel-iframe.html": [ + [ + {} + ] + ], + "wasm/serialization/resources/broadcastchannel-sharedworker.js": [ + [ + {} + ] + ], + "wasm/serialization/resources/broadcastchannel-worker.js": [ + [ + {} + ] + ], + "wasm/serialization/resources/create-empty-wasm-module.js": [ + [ + {} + ] + ], + "wasm/serialization/resources/echo-iframe.html": [ + [ + {} + ] + ], + "wasm/serialization/resources/echo-worker.js": [ + [ + {} + ] + ], + "wasm/serialization/resources/incrementer-iframe-domain.sub.html": [ + [ + {} + ] + ], + "wasm/serialization/resources/incrementer-iframe.html": [ + [ + {} + ] + ], + "wasm/serialization/resources/incrementer-popup.html": [ + [ + {} + ] + ], + "wasm/serialization/resources/incrementer-worker-with-channel.js": [ + [ + {} + ] + ], + "wasm/serialization/resources/incrementer-worker.js": [ + [ + {} + ] + ], + "wasm/serialization/resources/incrementer.wasm": [ + [ + {} + ] + ], + "wasm/serialization/resources/nested-iframe-1.html": [ + [ + {} + ] + ], + "wasm/serialization/resources/nested-iframe-2.html": [ + [ + {} + ] + ], + "wasm/serialization/resources/nested-iframe-3.html": [ + [ + {} + ] + ], + "wasm/serialization/resources/nested-iframe-4-incrementer.html": [ + [ + {} + ] + ], + "wasm/serialization/resources/serviceworker-failure.js": [ + [ + {} + ] + ], + "wasm/serialization/resources/sharedworker-failure.js": [ + [ + {} + ] + ], + "wasm/serialization/resources/test-incrementer.js": [ [ {} ] @@ -395416,21 +395491,99 @@ {} ] ], - "wasm/wasm_local_iframe_test.html": [ + "wasm/serialization/broadcastchannel-success-and-failure.html": [ [ - "/wasm/wasm_local_iframe_test.html", + "/wasm/serialization/broadcastchannel-success-and-failure.html", {} ] ], - "wasm/wasm_serialization_tests.html": [ + "wasm/serialization/broadcastchannel-success.html": [ [ - "/wasm/wasm_serialization_tests.html", + "/wasm/serialization/broadcastchannel-success.html", {} ] ], - "wasm/wasm_service_worker_test.https.html": [ + "wasm/serialization/identity-not-preserved.html": [ [ - "/wasm/wasm_service_worker_test.https.html", + "/wasm/serialization/identity-not-preserved.html", + {} + ] + ], + "wasm/serialization/nested-worker-success.any.js": [ + [ + "/wasm/serialization/nested-worker-success.any.sharedworker.html", + {} + ], + [ + "/wasm/serialization/nested-worker-success.any.worker.html", + {} + ] + ], + "wasm/serialization/no-transferring.html": [ + [ + "/wasm/serialization/no-transferring.html", + {} + ] + ], + "wasm/serialization/serialization-via-history.html": [ + [ + "/wasm/serialization/serialization-via-history.html", + {} + ] + ], + "wasm/serialization/serialization-via-idb.any.js": [ + [ + "/wasm/serialization/serialization-via-idb.any.html", + {} + ], + [ + "/wasm/serialization/serialization-via-idb.any.worker.html", + {} + ] + ], + "wasm/serialization/serialization-via-notifications-api.any.js": [ + [ + "/wasm/serialization/serialization-via-notifications-api.any.html", + {} + ], + [ + "/wasm/serialization/serialization-via-notifications-api.any.worker.html", + {} + ] + ], + "wasm/serialization/window-domain-success.sub.html": [ + [ + "/wasm/serialization/window-domain-success.sub.html", + {} + ] + ], + "wasm/serialization/window-messagechannel-success.html": [ + [ + "/wasm/serialization/window-messagechannel-success.html", + {} + ] + ], + "wasm/serialization/window-serviceworker-failure.https.html": [ + [ + "/wasm/serialization/window-serviceworker-failure.https.html", + {} + ] + ], + "wasm/serialization/window-sharedworker-failure.html": [ + [ + "/wasm/serialization/window-sharedworker-failure.html", + {} + ] + ], + "wasm/serialization/window-similar-but-cross-origin-success.sub.html": [ + [ + "/wasm/serialization/window-similar-but-cross-origin-success.sub.html", + {} + ] + ], + "wasm/serialization/window-simple-success.html": [ + [ + "/wasm/serialization/window-simple-success.html", {} ] ], @@ -598898,7 +599051,7 @@ "support" ], "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/sharedworker-failure.js": [ - "a11ccbc1f3099a6be7b4d538bcbe40292eac3ea0", + "8472318abd53207ec56b3f5988fb0a49d0c006a4", "support" ], "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/test-incrementer.js": [ @@ -649349,44 +649502,148 @@ "6e9284e773105db5751c5483ed9333a45272b180", "support" ], - "wasm/resources/blank.html": [ - "a3c3a4689a62b45b1e429f6b7a94690e556a1259", - "support" - ], - "wasm/resources/frame.html": [ - "d1c83e114a039a7aeefa8914340911eb2301b5e4", - "support" - ], - "wasm/resources/incrementer.wasm": [ - "47afcdef2a2812acccecd0f203d30d3023593f3d", - "support" - ], "wasm/resources/load_wasm.js": [ "512324639059da8a9d76e9d740d97fc56ebdebc4", "support" ], - "wasm/resources/service-worker.js": [ - "684eaf64878c22afc9ac877b79db7d26f14a3670", - "support" - ], - "wasm/wasm_local_iframe_test.html": [ - "0f4fbd0c7191ece3a901b0a065f147c03431a2d4", + "wasm/serialization/broadcastchannel-success-and-failure.html": [ + "0d11cc595be2d16ad795be8199ed2ae7abe79974", "testharness" ], - "wasm/wasm_serialization_tests.html": [ - "49766c770525bcef9d66ee0b735e410bc5a7ebb8", + "wasm/serialization/broadcastchannel-success.html": [ + "cd5f8d0b56a19148dbd01b4218869f1f0c3526fd", "testharness" ], - "wasm/wasm_serialization_tests.js": [ - "3cc4166168b08f46ce54511b6364d01f7b8cbeb9", + "wasm/serialization/identity-not-preserved.html": [ + "24bb3b16d8c50600a634d62d4c48c49dfb3b120e", + "testharness" + ], + "wasm/serialization/incrementer.wasm": [ + "47afcdef2a2812acccecd0f203d30d3023593f3d", "support" ], - "wasm/wasm_serialization_worker.js": [ - "3361ed73951770b2a6e881ef093a116d10676939", + "wasm/serialization/nested-worker-success.any.js": [ + "5388ebcc39b22946957250004577a1966c264a5a", + "testharness" + ], + "wasm/serialization/no-transferring.html": [ + "a0bf11f01dd459b2e3abeb249f725e1e05d1532f", + "testharness" + ], + "wasm/serialization/resources/blank.html": [ + "a3c3a4689a62b45b1e429f6b7a94690e556a1259", "support" ], - "wasm/wasm_service_worker_test.https.html": [ - "cced4b8f6ecdaa03c6d80793c2f3650b217452a5", + "wasm/serialization/resources/broadcastchannel-iframe.html": [ + "83e347b5cb35c92aa3cd96263a68b56af366f0e3", + "support" + ], + "wasm/serialization/resources/broadcastchannel-sharedworker.js": [ + "310e0e9358446acaec0f13d8e2fb4437316953c2", + "support" + ], + "wasm/serialization/resources/broadcastchannel-worker.js": [ + "76a8177060498547ab1661319c20d5d5288cd96f", + "support" + ], + "wasm/serialization/resources/create-empty-wasm-module.js": [ + "7326710c9e47d756bbdab1ead2303b108b8f04db", + "support" + ], + "wasm/serialization/resources/echo-iframe.html": [ + "c4fd5824a1c617c21fe8b92483b388d586edf06e", + "support" + ], + "wasm/serialization/resources/echo-worker.js": [ + "cbbde8a73c8c2a63cc97cbe2b6cd7c6d81585b5c", + "support" + ], + "wasm/serialization/resources/incrementer-iframe-domain.sub.html": [ + "d2d18de49950c2508a69545ad95a937898b04532", + "support" + ], + "wasm/serialization/resources/incrementer-iframe.html": [ + "5c8bc0735e207a7c18f12d578276ae3c3b999da5", + "support" + ], + "wasm/serialization/resources/incrementer-popup.html": [ + "660e472b27c086068edeb7fd2bcade536c4bd5e9", + "support" + ], + "wasm/serialization/resources/incrementer-worker-with-channel.js": [ + "0323b3e52e75e894ae40ffc68e904ffc81ded024", + "support" + ], + "wasm/serialization/resources/incrementer-worker.js": [ + "1779ceea520ccfd07da6d595d8a34be62de89428", + "support" + ], + "wasm/serialization/resources/incrementer.wasm": [ + "47afcdef2a2812acccecd0f203d30d3023593f3d", + "support" + ], + "wasm/serialization/resources/nested-iframe-1.html": [ + "fe93cc0c4b0fe5b86bf1a12de84fb3fc48ea08a5", + "support" + ], + "wasm/serialization/resources/nested-iframe-2.html": [ + "fad52ce9de3977c077b5a22e72ee7b23837ea302", + "support" + ], + "wasm/serialization/resources/nested-iframe-3.html": [ + "7971022b2cdc315d598761a3694838494c2884a8", + "support" + ], + "wasm/serialization/resources/nested-iframe-4-incrementer.html": [ + "f419f4bc36cdffafa665e333a7e7bced3d153585", + "support" + ], + "wasm/serialization/resources/serviceworker-failure.js": [ + "39796f9d94a39d2a13ed832544ce781373a20655", + "support" + ], + "wasm/serialization/resources/sharedworker-failure.js": [ + "854c70b9e84e6e6fb1c59f64a06a79646a122576", + "support" + ], + "wasm/serialization/resources/test-incrementer.js": [ + "65cb33227a37376c1a0134275d5079d442b443a9", + "support" + ], + "wasm/serialization/serialization-via-history.html": [ + "35dc17b6701fadf920ce251ec6c63da1c26b6570", + "testharness" + ], + "wasm/serialization/serialization-via-idb.any.js": [ + "1d861c3d3aa1072b1c90332fec7ac993d3b59552", + "testharness" + ], + "wasm/serialization/serialization-via-notifications-api.any.js": [ + "84105651d3b53192f453b9f16bb85163165495cb", + "testharness" + ], + "wasm/serialization/window-domain-success.sub.html": [ + "51d4c5cb0ea0c0c5cf69530876c2f7c19bb3830a", + "testharness" + ], + "wasm/serialization/window-messagechannel-success.html": [ + "e686c8113561d94e860a774771aa69b974696716", + "testharness" + ], + "wasm/serialization/window-serviceworker-failure.https.html": [ + "97c5a1decdb85317930508ece8f306fb80880ca2", + "testharness" + ], + "wasm/serialization/window-sharedworker-failure.html": [ + "667e985a30b53c0ecadfd4c68f6217b87a7a5b98", + "testharness" + ], + "wasm/serialization/window-similar-but-cross-origin-success.sub.html": [ + "070cf0a49a8f0c0ede81b6751e727b44f36c0043", + "testharness" + ], + "wasm/serialization/window-simple-success.html": [ + "6f2ccf465e93a160c73df548fc58774a5040f0e6", "testharness" ], "web-animations/META.yml": [ 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 index a11ccbc1f309..8472318abd53 100644 --- 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 @@ -1,16 +1,17 @@ let state = "send-sw-failure" onconnect = initialE => { - initialE.source.postMessage(state) - initialE.source.onmessage = e => { + let port = initialE.source; + port.postMessage(state) + port.onmessage = e => { if(state === "" && e.data === "send-window-failure") { - e.postMessage(new SharedArrayBuffer()) + port.postMessage(new SharedArrayBuffer()) } else { - e.postMessage("failure") + port.postMessage("failure") } } - initialE.source.onmessageerror = e => { + port.onmessageerror = e => { if(state === "send-sw-failure") { - e.postMessage("send-sw-failure-success") + port.postMessage("send-sw-failure-success") state = "" } } diff --git a/testing/web-platform/tests/wasm/resources/frame.html b/testing/web-platform/tests/wasm/resources/frame.html deleted file mode 100644 index d1c83e114a03..000000000000 --- a/testing/web-platform/tests/wasm/resources/frame.html +++ /dev/null @@ -1,18 +0,0 @@ - diff --git a/testing/web-platform/tests/wasm/resources/service-worker.js b/testing/web-platform/tests/wasm/resources/service-worker.js deleted file mode 100644 index 684eaf64878c..000000000000 --- a/testing/web-platform/tests/wasm/resources/service-worker.js +++ /dev/null @@ -1,30 +0,0 @@ -var port; - -importScripts('load_wasm.js'); - -self.onmessage = function(e) { - var message = e.data; - if ('port' in message) { - port = message.port; - } -}; - -// And an event listener: -self.addEventListener('message', function(e) { - var message = e.data; - if ("compile" in message) { - createWasmModule() - .then(m => { - try { - port.postMessage({type:"OK", module:m}); - } catch (e) { - port.postMessage({type:"SEND ERROR"}); - } - }) - .catch(e => port.postMessage({type:"OTHER ERROR"})); - } -}); - -self.addEventListener('messageerror', function(e) { - port.postMessage({type:"RECEIVE ERROR"}); -}); diff --git a/testing/web-platform/tests/wasm/serialization/broadcastchannel-success-and-failure.html b/testing/web-platform/tests/wasm/serialization/broadcastchannel-success-and-failure.html new file mode 100644 index 000000000000..0d11cc595be2 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/broadcastchannel-success-and-failure.html @@ -0,0 +1,38 @@ + + +WebAssembly.Module cannot cross agent clusters, BroadcastChannel edition + + + + diff --git a/testing/web-platform/tests/wasm/serialization/broadcastchannel-success.html b/testing/web-platform/tests/wasm/serialization/broadcastchannel-success.html new file mode 100644 index 000000000000..cd5f8d0b56a1 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/broadcastchannel-success.html @@ -0,0 +1,59 @@ + + + +Structured cloning of WebAssembly.Module: BroadcastChannel within the same agent cluster + + + + +
+ + diff --git a/testing/web-platform/tests/wasm/serialization/identity-not-preserved.html b/testing/web-platform/tests/wasm/serialization/identity-not-preserved.html new file mode 100644 index 000000000000..24bb3b16d8c5 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/identity-not-preserved.html @@ -0,0 +1,66 @@ + + + +WebAssembly.Modules, when cloned, do not give back the same object + + + + +
+ + diff --git a/testing/web-platform/tests/wasm/resources/incrementer.wasm b/testing/web-platform/tests/wasm/serialization/incrementer.wasm similarity index 100% rename from testing/web-platform/tests/wasm/resources/incrementer.wasm rename to testing/web-platform/tests/wasm/serialization/incrementer.wasm diff --git a/testing/web-platform/tests/wasm/serialization/nested-worker-success.any.js b/testing/web-platform/tests/wasm/serialization/nested-worker-success.any.js new file mode 100644 index 000000000000..5388ebcc39b2 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/nested-worker-success.any.js @@ -0,0 +1,9 @@ +// META: global=!default,dedicatedworker,sharedworker +// META: script=resources/test-incrementer.js +"use strict"; + +promise_test(t => { + const worker = new Worker("resources/incrementer-worker.js"); + + return testSharingViaIncrementerScript(t, worker, "parent worker", worker, "sub-worker"); +}, "postMessaging to a dedicated sub-worker allows them to see each others' modifications"); diff --git a/testing/web-platform/tests/wasm/serialization/no-transferring.html b/testing/web-platform/tests/wasm/serialization/no-transferring.html new file mode 100644 index 000000000000..a0bf11f01dd4 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/no-transferring.html @@ -0,0 +1,31 @@ + + + +WebAssembly.Modules cannot be transferred + + + + + diff --git a/testing/web-platform/tests/wasm/resources/blank.html b/testing/web-platform/tests/wasm/serialization/resources/blank.html similarity index 100% rename from testing/web-platform/tests/wasm/resources/blank.html rename to testing/web-platform/tests/wasm/serialization/resources/blank.html diff --git a/testing/web-platform/tests/wasm/serialization/resources/broadcastchannel-iframe.html b/testing/web-platform/tests/wasm/serialization/resources/broadcastchannel-iframe.html new file mode 100644 index 000000000000..83e347b5cb35 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/broadcastchannel-iframe.html @@ -0,0 +1,20 @@ + + +A test page that uses a given WebAssembly.Module sent from a BroadcastChannel + + diff --git a/testing/web-platform/tests/wasm/serialization/resources/broadcastchannel-sharedworker.js b/testing/web-platform/tests/wasm/serialization/resources/broadcastchannel-sharedworker.js new file mode 100644 index 000000000000..310e0e935844 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/broadcastchannel-sharedworker.js @@ -0,0 +1,7 @@ +const channel = new BroadcastChannel("anne was here"); +channel.onmessageerror = ({ data }) => { + if(data === null) { + channel.postMessage("sw-success"); + } +} +channel.postMessage("hi"); diff --git a/testing/web-platform/tests/wasm/serialization/resources/broadcastchannel-worker.js b/testing/web-platform/tests/wasm/serialization/resources/broadcastchannel-worker.js new file mode 100644 index 000000000000..76a817706049 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/broadcastchannel-worker.js @@ -0,0 +1,9 @@ +const channel = new BroadcastChannel("anne was here"); +channel.onmessage = ({ data }) => { + if(data === "hi" || data === "sw-success") { + return; + } else if(data instanceof WebAssembly.Module) { + channel.postMessage("dw-success"); + } +} +channel.postMessage("hi"); diff --git a/testing/web-platform/tests/wasm/serialization/resources/create-empty-wasm-module.js b/testing/web-platform/tests/wasm/serialization/resources/create-empty-wasm-module.js new file mode 100644 index 000000000000..7326710c9e47 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/create-empty-wasm-module.js @@ -0,0 +1,4 @@ +function createEmptyWasmModule() { + return new WebAssembly.Module( + new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00])); +} diff --git a/testing/web-platform/tests/wasm/serialization/resources/echo-iframe.html b/testing/web-platform/tests/wasm/serialization/resources/echo-iframe.html new file mode 100644 index 000000000000..c4fd5824a1c6 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/echo-iframe.html @@ -0,0 +1,11 @@ + + +A test page that echos back anything postMessaged to it to its parent + + diff --git a/testing/web-platform/tests/wasm/serialization/resources/echo-worker.js b/testing/web-platform/tests/wasm/serialization/resources/echo-worker.js new file mode 100644 index 000000000000..cbbde8a73c8c --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/echo-worker.js @@ -0,0 +1,5 @@ +"use strict"; + +self.onmessage = ({ data }) => { + self.postMessage(data); +}; diff --git a/testing/web-platform/tests/wasm/serialization/resources/incrementer-iframe-domain.sub.html b/testing/web-platform/tests/wasm/serialization/resources/incrementer-iframe-domain.sub.html new file mode 100644 index 000000000000..d2d18de49950 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/incrementer-iframe-domain.sub.html @@ -0,0 +1,12 @@ + + +A test page that is sent a WebAssembly Module + + + + diff --git a/testing/web-platform/tests/wasm/serialization/resources/incrementer-iframe.html b/testing/web-platform/tests/wasm/serialization/resources/incrementer-iframe.html new file mode 100644 index 000000000000..5c8bc0735e20 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/incrementer-iframe.html @@ -0,0 +1,11 @@ + + +A test page that is sent a WebAssembly Module + + + + diff --git a/testing/web-platform/tests/wasm/serialization/resources/incrementer-popup.html b/testing/web-platform/tests/wasm/serialization/resources/incrementer-popup.html new file mode 100644 index 000000000000..660e472b27c0 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/incrementer-popup.html @@ -0,0 +1,11 @@ + + +A test page that is sent a WebAssembly Module + + + + diff --git a/testing/web-platform/tests/wasm/serialization/resources/incrementer-worker-with-channel.js b/testing/web-platform/tests/wasm/serialization/resources/incrementer-worker-with-channel.js new file mode 100644 index 000000000000..0323b3e52e75 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/incrementer-worker-with-channel.js @@ -0,0 +1,8 @@ +"use strict"; +importScripts("/resources/testharness.js"); +importScripts("./test-incrementer.js"); + +self.onmessage = ({ data }) => { + // data will be a MessagePort + setupDestinationIncrementer(data, data); +}; diff --git a/testing/web-platform/tests/wasm/serialization/resources/incrementer-worker.js b/testing/web-platform/tests/wasm/serialization/resources/incrementer-worker.js new file mode 100644 index 000000000000..1779ceea520c --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/incrementer-worker.js @@ -0,0 +1,5 @@ +"use strict"; +importScripts("/resources/testharness.js"); +importScripts("./test-incrementer.js"); + +setupDestinationIncrementer(self, self); diff --git a/testing/web-platform/tests/wasm/serialization/resources/incrementer.wasm b/testing/web-platform/tests/wasm/serialization/resources/incrementer.wasm new file mode 100644 index 000000000000..47afcdef2a28 Binary files /dev/null and b/testing/web-platform/tests/wasm/serialization/resources/incrementer.wasm differ diff --git a/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-1.html b/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-1.html new file mode 100644 index 000000000000..fe93cc0c4b0f --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-1.html @@ -0,0 +1,5 @@ + + +Nesting level 1 + + diff --git a/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-2.html b/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-2.html new file mode 100644 index 000000000000..fad52ce9de39 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-2.html @@ -0,0 +1,5 @@ + + +Nesting level 2 + + diff --git a/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-3.html b/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-3.html new file mode 100644 index 000000000000..7971022b2cdc --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-3.html @@ -0,0 +1,5 @@ + + +Nesting level 3 + + diff --git a/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-4-incrementer.html b/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-4-incrementer.html new file mode 100644 index 000000000000..f419f4bc36cd --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/nested-iframe-4-incrementer.html @@ -0,0 +1,11 @@ + + +A test page that is sent a WebAssembly Module, nested 4 levels deep in iframes + + + + diff --git a/testing/web-platform/tests/wasm/serialization/resources/serviceworker-failure.js b/testing/web-platform/tests/wasm/serialization/resources/serviceworker-failure.js new file mode 100644 index 000000000000..39796f9d94a3 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/serviceworker-failure.js @@ -0,0 +1,34 @@ +// Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/. +"use strict"; +self.importScripts("/resources/testharness.js"); +self.importScripts("./create-empty-wasm-module.js"); + +let state = "start in worker"; + +self.onmessage = e => { + if (e.data === "start in window") { + assert_equals(state, "start in worker"); + e.source.postMessage(state); + state = "we are expecting a messageerror due to the window sending us a WebAssembly.Module"; + } else if (e.data === "we are expecting a messageerror due to the worker sending us a WebAssembly.Module") { + assert_equals(state, "onmessageerror was received in worker"); + e.source.postMessage(createEmptyWasmModule()); + state = "done in worker"; + } else { + e.source.postMessage(`worker onmessage was reached when in state "${state}" and data ${e.data}`); + } +}; + +self.onmessageerror = e => { + if (state === "we are expecting a messageerror due to the window sending us a WebAssembly.Module") { + assert_equals(e.data, null, "data"); + assert_equals(e.origin, self.origin, "origin"); + assert_not_equals(e.source, null, "source"); + assert_equals(e.ports.length, 0, "ports length"); + + state = "onmessageerror was received in worker"; + e.source.postMessage(state); + } else { + e.source.postMessage(`worker onmessageerror was reached when in state "${state}" and data ${e.data}`); + } +}; diff --git a/testing/web-platform/tests/wasm/serialization/resources/sharedworker-failure.js b/testing/web-platform/tests/wasm/serialization/resources/sharedworker-failure.js new file mode 100644 index 000000000000..854c70b9e84e --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/sharedworker-failure.js @@ -0,0 +1,21 @@ +importScripts("./test-incrementer.js"); +importScripts("./create-empty-wasm-module.js"); + +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(createEmptyWasmModule()) + } else { + port.postMessage("failure") + } + } + port.onmessageerror = e => { + if(state === "send-sw-failure") { + port.postMessage("send-sw-failure-success") + state = "" + } + } +} diff --git a/testing/web-platform/tests/wasm/serialization/resources/test-incrementer.js b/testing/web-platform/tests/wasm/serialization/resources/test-incrementer.js new file mode 100644 index 000000000000..65cb33227a37 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/resources/test-incrementer.js @@ -0,0 +1,57 @@ +// Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/. +// +// This file is simplified from the one there, because it only tests that the +// module can be passed and that functions can be run. The SharedArrayBuffer +// version also tests that the memory is shared between the agents. + +"use strict"; + +function createWasmModule() { + return fetch('incrementer.wasm') + .then(response => { + if (!response.ok) + throw new Error(response.statusText); + return response.arrayBuffer(); + }) + .then(WebAssembly.compile); +} + +function testModule(module) { + let instance = new WebAssembly.Instance(module); + let increment = instance.exports["increment"]; + assert_equals(typeof increment, "function", `The type of the increment export should be "function", got ${typeof increment}`); + let result = increment(42); + assert_equals(result, 43, `increment(42) should be 43, got ${result}`); +} + +self.testSharingViaIncrementerScript = (t, whereToListen, whereToListenLabel, whereToSend, whereToSendLabel, origin) => { + return createWasmModule().then(module => { + return new Promise(resolve => { + + whereToListen.onmessage = t.step_func(({ data }) => { + switch (data.message) { + case "module received": { + testModule(data.module); + resolve(); + break; + } + } + }); + + whereToSend.postMessage({ message: "send module", module }, origin); + }); + }); +}; + +self.setupDestinationIncrementer = (whereToListen, whereToSendBackTo, origin) => { + whereToListen.onmessage = ({ data }) => { + switch (data.message) { + case "send module": { + let module = data.module; + testModule(data.module); + whereToSendBackTo.postMessage({ message: "module received", module }, origin); + break; + } + } + }; +}; diff --git a/testing/web-platform/tests/wasm/serialization/serialization-via-history.html b/testing/web-platform/tests/wasm/serialization/serialization-via-history.html new file mode 100644 index 000000000000..35dc17b6701f --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/serialization-via-history.html @@ -0,0 +1,34 @@ + + + +WebAssembly.Module cloning via history's methods invoking StructuredSerializeForStorage + + + + + diff --git a/testing/web-platform/tests/wasm/serialization/serialization-via-idb.any.js b/testing/web-platform/tests/wasm/serialization/serialization-via-idb.any.js new file mode 100644 index 000000000000..1d861c3d3aa1 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/serialization-via-idb.any.js @@ -0,0 +1,45 @@ +// META: script=/IndexedDB/support.js +"use strict"; + +function createEmptyWasmModule() { + return new WebAssembly.Module( + new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00])); +} + +async_test(t => { + const openReq = createdb(t); + + openReq.onupgradeneeded = e => { + const db = e.target.result; + const store = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws("DataCloneError", () => { + store.put({ key: 1, property: createEmptyWasmModule() }); + }); + t.done(); + }; +}, "WebAssembly.Module cloning via IndexedDB: basic case"); + +async_test(t => { + const openReq = createdb(t); + + openReq.onupgradeneeded = e => { + const db = e.target.result; + const store = db.createObjectStore("store", { keyPath: "key" }); + + let getter1Called = false; + let getter2Called = false; + + assert_throws("DataCloneError", () => { + store.put({ key: 1, property: [ + { get x() { getter1Called = true; return 5; } }, + createEmptyWasmModule(), + { get x() { getter2Called = true; return 5; } } + ]}); + }); + + assert_true(getter1Called, "The getter before the WebAssembly.Module must have been called"); + assert_false(getter2Called, "The getter after the WebAssembly.Module must not have been called"); + t.done(); + }; +}, "WebAssembly.Module cloning via the IndexedDB: is interleaved correctly"); diff --git a/testing/web-platform/tests/wasm/serialization/serialization-via-notifications-api.any.js b/testing/web-platform/tests/wasm/serialization/serialization-via-notifications-api.any.js new file mode 100644 index 000000000000..84105651d3b5 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/serialization-via-notifications-api.any.js @@ -0,0 +1,28 @@ +"use strict"; + +function createEmptyWasmModule() { + return new WebAssembly.Module( + new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00])); +} + +test(() => { + assert_throws("DataCloneError", () => { + new Notification("Bob: Hi", { data: createEmptyWasmModule() }); + }) +}, "WebAssembly.Module cloning via the Notifications API's data member: basic case"); + +test(() => { + let getter1Called = false; + let getter2Called = false; + + assert_throws("DataCloneError", () => { + new Notification("Bob: Hi", { data: [ + { get x() { getter1Called = true; return 5; } }, + createEmptyWasmModule(), + { get x() { getter2Called = true; return 5; } } + ]}); + }); + + assert_true(getter1Called, "The getter before the SAB must have been called"); + assert_false(getter2Called, "The getter after the SAB must not have been called"); +}, "WebAssembly.Module cloning via the Notifications API's data member: is interleaved correctly"); diff --git a/testing/web-platform/tests/wasm/serialization/window-domain-success.sub.html b/testing/web-platform/tests/wasm/serialization/window-domain-success.sub.html new file mode 100644 index 000000000000..51d4c5cb0ea0 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/window-domain-success.sub.html @@ -0,0 +1,26 @@ + + + +Structured cloning of WebAssembly.Module into same-origin-domain windows + + + + +
+ + diff --git a/testing/web-platform/tests/wasm/serialization/window-messagechannel-success.html b/testing/web-platform/tests/wasm/serialization/window-messagechannel-success.html new file mode 100644 index 000000000000..e686c8113561 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/window-messagechannel-success.html @@ -0,0 +1,21 @@ + + + +Structured cloning of WebAssembly.Module using MessageChannel + + + + +
+ + diff --git a/testing/web-platform/tests/wasm/serialization/window-serviceworker-failure.https.html b/testing/web-platform/tests/wasm/serialization/window-serviceworker-failure.https.html new file mode 100644 index 000000000000..97c5a1decdb8 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/window-serviceworker-failure.https.html @@ -0,0 +1,54 @@ + + + +WebAssembly.Module cannot cross agent clusters, service worker edition + + + + + + diff --git a/testing/web-platform/tests/wasm/serialization/window-sharedworker-failure.html b/testing/web-platform/tests/wasm/serialization/window-sharedworker-failure.html new file mode 100644 index 000000000000..667e985a30b5 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/window-sharedworker-failure.html @@ -0,0 +1,33 @@ + + +WebAssembly.Modules cannot cross agent clusters, shared worker edition + + + + diff --git a/testing/web-platform/tests/wasm/serialization/window-similar-but-cross-origin-success.sub.html b/testing/web-platform/tests/wasm/serialization/window-similar-but-cross-origin-success.sub.html new file mode 100644 index 000000000000..070cf0a49a8f --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/window-similar-but-cross-origin-success.sub.html @@ -0,0 +1,25 @@ + + + +Structured cloning of WebAssembly.Module to similar-origin, but not same-origin, windows + + + + +
+ + diff --git a/testing/web-platform/tests/wasm/serialization/window-simple-success.html b/testing/web-platform/tests/wasm/serialization/window-simple-success.html new file mode 100644 index 000000000000..6f2ccf465e93 --- /dev/null +++ b/testing/web-platform/tests/wasm/serialization/window-simple-success.html @@ -0,0 +1,57 @@ + + + +Structured cloning of WebAssembly.Module: simple success cases that don't need dedicated files + + + + +
+ + diff --git a/testing/web-platform/tests/wasm/wasm_local_iframe_test.html b/testing/web-platform/tests/wasm/wasm_local_iframe_test.html deleted file mode 100644 index 0f4fbd0c7191..000000000000 --- a/testing/web-platform/tests/wasm/wasm_local_iframe_test.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - diff --git a/testing/web-platform/tests/wasm/wasm_serialization_tests.html b/testing/web-platform/tests/wasm/wasm_serialization_tests.html deleted file mode 100644 index 49766c770525..000000000000 --- a/testing/web-platform/tests/wasm/wasm_serialization_tests.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/testing/web-platform/tests/wasm/wasm_serialization_tests.js b/testing/web-platform/tests/wasm/wasm_serialization_tests.js deleted file mode 100644 index 3cc4166168b0..000000000000 --- a/testing/web-platform/tests/wasm/wasm_serialization_tests.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -function TestInstantiateInWorker() { - return createWasmModule() - .then((mod) => { - var worker = new Worker("wasm_serialization_worker.js"); - return new Promise((resolve, reject) => { - worker.postMessage(mod); - worker.onmessage = function(event) { - resolve(event.data); - } - }); - }) - .then(data => assert_equals(data, 43)) - .catch(error => assert_unreached(error)); -} diff --git a/testing/web-platform/tests/wasm/wasm_serialization_worker.js b/testing/web-platform/tests/wasm/wasm_serialization_worker.js deleted file mode 100644 index 3361ed739517..000000000000 --- a/testing/web-platform/tests/wasm/wasm_serialization_worker.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -onmessage = function(e) { - var compiled_module = e.data; - var instance = new WebAssembly.Instance(compiled_module); - if (instance === undefined) { - postMessage("error!"); - return; - } - var entrypoint = instance.exports["increment"]; - - if (typeof entrypoint !== "function") { - postMessage("error!"); - return; - } - - var ret = entrypoint(42); - postMessage(ret); -} diff --git a/testing/web-platform/tests/wasm/wasm_service_worker_test.https.html b/testing/web-platform/tests/wasm/wasm_service_worker_test.https.html deleted file mode 100644 index cced4b8f6ecd..000000000000 --- a/testing/web-platform/tests/wasm/wasm_service_worker_test.https.html +++ /dev/null @@ -1,23 +0,0 @@ - -Service Worker: postMessage with wasm - - - - -