зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1483451 [wpt PR 12488] - Add WPT serialization tests for wasm modules, a=testonly
Automatic update from web-platform-testsAdd WPT serialization tests for wasm modules These WPT tests are based on similar tests in wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ This also fixes some test failures for the SharedArrayBuffer tests. Bug: chromium:798572 Change-Id: I50b0edbebe4e97f5358513d248657d2831f48201 Reviewed-on: https://chromium-review.googlesource.com/1175490 Reviewed-by: Marijn Kruisselbrink <mek@chromium.org> Commit-Queue: Ben Smith <binji@chromium.org> Cr-Commit-Position: refs/heads/master@{#586480} -- wpt-commits: 3dae97c21757a4fdf03c43ccf5e68e4297d1b6ec wpt-pr: 12488 --HG-- rename : testing/web-platform/tests/wasm/resources/incrementer.wasm => testing/web-platform/tests/wasm/serialization/incrementer.wasm rename : testing/web-platform/tests/wasm/resources/blank.html => testing/web-platform/tests/wasm/serialization/resources/blank.html rename : testing/web-platform/tests/wasm/resources/incrementer.wasm => testing/web-platform/tests/wasm/serialization/resources/incrementer.wasm
This commit is contained in:
Родитель
f0316f94d6
Коммит
2191d691ca
|
@ -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": [
|
||||
|
|
|
@ -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 = ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<script>
|
||||
function listener(event) {
|
||||
var mod = event.data;
|
||||
try {
|
||||
var i = new WebAssembly.Instance(mod);
|
||||
var ans = i.exports.increment(42);
|
||||
event.source.postMessage(ans, event.origin);
|
||||
} catch (e) {
|
||||
event.source.postMessage(e, event.origin);
|
||||
}
|
||||
}
|
||||
|
||||
if (window.addEventListener){
|
||||
addEventListener("message", listener, false)
|
||||
} else {
|
||||
attachEvent("onmessage", listener)
|
||||
}
|
||||
</script>
|
|
@ -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"});
|
||||
});
|
|
@ -0,0 +1,38 @@
|
|||
<!doctype html>
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<title>WebAssembly.Module cannot cross agent clusters, BroadcastChannel edition</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/test-incrementer.js"></script>
|
||||
<script>
|
||||
async_test(t => {
|
||||
const channel = new BroadcastChannel("anne was here"),
|
||||
dw = new Worker("resources/broadcastchannel-worker.js"),
|
||||
sw = new SharedWorker("resources/broadcastchannel-sharedworker.js");
|
||||
let startCounter = 0,
|
||||
dwStatus = "unknown",
|
||||
swStatus = "unknown";
|
||||
|
||||
channel.onmessage = t.step_func(({ data }) => {
|
||||
if(data === "hi") {
|
||||
startCounter++;
|
||||
if(startCounter === 2) {
|
||||
createWasmModule().then(module => {
|
||||
channel.postMessage(module);
|
||||
});
|
||||
} else if(startCounter > 2) {
|
||||
assert_unreached();
|
||||
}
|
||||
} else if(data === "dw-success") {
|
||||
dwStatus = "success";
|
||||
} else if(data === "sw-success") {
|
||||
swStatus = "success";
|
||||
} else {
|
||||
assert_unreached();
|
||||
}
|
||||
if(dwStatus === "success" && swStatus === "success") {
|
||||
t.done();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<meta charset="utf-8">
|
||||
<title>Structured cloning of WebAssembly.Module: BroadcastChannel within the same agent cluster</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/test-incrementer.js"></script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
promise_test(t => {
|
||||
return createWasmModule().then(module => {
|
||||
let loadedIframes = 0;
|
||||
return Promise.all([
|
||||
createIFrame("resources/broadcastchannel-iframe.html"),
|
||||
createIFrame("resources/broadcastchannel-iframe.html"),
|
||||
createIFrame("resources/broadcastchannel-iframe.html")
|
||||
]).then(() => {
|
||||
const thisIframe = loadedIframes++;
|
||||
const channel = new BroadcastChannel("channel name");
|
||||
|
||||
return new Promise(resolve => {
|
||||
let soFar = 0;
|
||||
channel.onmessage = t.step_func(msg => {
|
||||
if (msg.module) {
|
||||
// We only care about "broadcasts" from the workers.
|
||||
return;
|
||||
}
|
||||
|
||||
let {i, result} = msg;
|
||||
|
||||
assert_in_array(i, [0, 1, 2], "Any message events must come from expected sources");
|
||||
assert_equals(result, i + 1, `iframe ${i} must return ${i+1}`);
|
||||
++soFar;
|
||||
|
||||
if (soFar === 3) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
channel.postMessage({ module, i: thisIframe });
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function createIFrame(src) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.src = src;
|
||||
iframe.onload = () => resolve(iframe);
|
||||
iframe.onerror = () => reject(`iframe with URL ${src} failed to load`);
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<meta charset="utf-8">
|
||||
<title>WebAssembly.Modules, when cloned, do not give back the same object</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/test-incrementer.js"></script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
async_test(t => {
|
||||
createWasmModule().then(module => {
|
||||
window.addEventListener("message", t.step_func(({ data }) => {
|
||||
if (data.testId !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert_not_equals(data.module, module);
|
||||
|
||||
t.done();
|
||||
}));
|
||||
|
||||
window.postMessage({ module, testId: 1 }, "*");
|
||||
});
|
||||
}, "postMessaging to this window does not give back the same WebAssembly.Module");
|
||||
|
||||
async_test(t => {
|
||||
createWasmModule().then(module => {
|
||||
const worker = new Worker("resources/echo-worker.js");
|
||||
|
||||
worker.addEventListener("message", t.step_func(({ data }) => {
|
||||
if (data.testId !== 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert_not_equals(data.module, module);
|
||||
t.done();
|
||||
}));
|
||||
|
||||
worker.postMessage({ testId: 2, module });
|
||||
});
|
||||
}, "postMessaging to a worker and back does not give back the same WebAssembly.Module");
|
||||
|
||||
async_test(t => {
|
||||
createWasmModule().then(module => {
|
||||
window.addEventListener("message", t.step_func(({ data }) => {
|
||||
if (data.testId !== 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert_not_equals(data.module, module);
|
||||
t.done();
|
||||
}));
|
||||
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.onload = t.step_func(() => {
|
||||
iframe.contentWindow.postMessage({ testId: 3, module }, "*");
|
||||
});
|
||||
iframe.src = "resources/echo-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
}, "postMessaging to an iframe and back does not give back the same WebAssembly.Module");
|
||||
</script>
|
|
@ -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");
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<meta charset="utf-8">
|
||||
<title>WebAssembly.Modules cannot be transferred</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/create-empty-wasm-module.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
test(() => {
|
||||
const module = createEmptyWasmModule();
|
||||
assert_throws("DataCloneError", () => window.postMessage(module, "*", [module]));
|
||||
assert_throws("DataCloneError", () => window.postMessage("test", "*", [module]));
|
||||
}, "Trying to transfer a WebAssembly.Module to this window throws");
|
||||
|
||||
test(() => {
|
||||
const module = createEmptyWasmModule();
|
||||
const worker = new Worker("resources/echo-worker.js");
|
||||
assert_throws("DataCloneError", () => worker.postMessage(module, [module]));
|
||||
assert_throws("DataCloneError", () => worker.postMessage("test", [module]));
|
||||
}, "Trying to transfer a WebAssembly.Module to a worker throws");
|
||||
|
||||
test(() => {
|
||||
const module = createEmptyWasmModule();
|
||||
const channel = new MessageChannel();
|
||||
assert_throws("DataCloneError", () => channel.port1.postMessage(module, [module]));
|
||||
assert_throws("DataCloneError", () => channel.port1.postMessage("test", [module]));
|
||||
}, "Trying to transfer a WebAssembly.Module through a MessagePort throws");
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>A test page that uses a given WebAssembly.Module sent from a BroadcastChannel</title>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
const channel = new BroadcastChannel("channel name");
|
||||
|
||||
channel.onmessage = ({ data: { module, i }, source }) => {
|
||||
if (!module) {
|
||||
// We only care about "broadcasts" from the window
|
||||
return;
|
||||
}
|
||||
|
||||
let instance = new WebAssembly.Instance(module);
|
||||
let increment = instance.exports["increment"];
|
||||
let result = increment(i);
|
||||
channel.postMessage({i, result});
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,7 @@
|
|||
const channel = new BroadcastChannel("anne was here");
|
||||
channel.onmessageerror = ({ data }) => {
|
||||
if(data === null) {
|
||||
channel.postMessage("sw-success");
|
||||
}
|
||||
}
|
||||
channel.postMessage("hi");
|
|
@ -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");
|
|
@ -0,0 +1,4 @@
|
|||
function createEmptyWasmModule() {
|
||||
return new WebAssembly.Module(
|
||||
new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]));
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>A test page that echos back anything postMessaged to it to its parent</title>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
window.onmessage = ({ data }) => {
|
||||
parent.postMessage(data, "*");
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
self.onmessage = ({ data }) => {
|
||||
self.postMessage(data);
|
||||
};
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>A test page that is sent a WebAssembly Module</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="test-incrementer.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
document.domain = "{{host}}";
|
||||
setupDestinationIncrementer(self, parent, "*");
|
||||
</script>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>A test page that is sent a WebAssembly Module</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="test-incrementer.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
setupDestinationIncrementer(self, parent, "*");
|
||||
</script>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>A test page that is sent a WebAssembly Module</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="test-incrementer.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
setupDestinationIncrementer(self, opener, "*");
|
||||
</script>
|
|
@ -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);
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("./test-incrementer.js");
|
||||
|
||||
setupDestinationIncrementer(self, self);
|
Двоичные данные
testing/web-platform/tests/wasm/serialization/resources/incrementer.wasm
Normal file
Двоичные данные
testing/web-platform/tests/wasm/serialization/resources/incrementer.wasm
Normal file
Двоичный файл не отображается.
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Nesting level 1</title>
|
||||
|
||||
<iframe src="nested-iframe-2.html"></iframe>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Nesting level 2</title>
|
||||
|
||||
<iframe src="nested-iframe-3.html"></iframe>
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Nesting level 3</title>
|
||||
|
||||
<iframe src="nested-iframe-4-incrementer.html"></iframe>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>A test page that is sent a WebAssembly Module, nested 4 levels deep in iframes</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="test-incrementer.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
setupDestinationIncrementer(self, parent.parent.parent.parent.parent, "*");
|
||||
</script>
|
|
@ -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}`);
|
||||
}
|
||||
};
|
|
@ -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 = ""
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<meta charset="utf-8">
|
||||
<title>WebAssembly.Module cloning via history's methods invoking StructuredSerializeForStorage</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/create-empty-wasm-module.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
for (const method of ["pushState", "replaceState"]) {
|
||||
test(() => {
|
||||
assert_throws("DataCloneError", () => {
|
||||
history[method](createEmptyWasmModule(), "dummy title");
|
||||
});
|
||||
}, `history.${method}(): simple case`);
|
||||
|
||||
test(() => {
|
||||
let getter1Called = false;
|
||||
let getter2Called = false;
|
||||
assert_throws("DataCloneError", () => {
|
||||
history[method]([
|
||||
{ get x() { getter1Called = true; return 5; } },
|
||||
createEmptyWasmModule(),
|
||||
{ get x() { getter2Called = true; return 5; } }
|
||||
], "dummy title");
|
||||
});
|
||||
|
||||
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");
|
||||
}, `history.${method}(): is interleaved correctly`);
|
||||
}
|
||||
</script>
|
|
@ -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");
|
|
@ -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");
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<meta charset="utf-8">
|
||||
<title>Structured cloning of WebAssembly.Module into same-origin-domain windows</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/test-incrementer.js"></script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
document.domain = "{{host}}";
|
||||
|
||||
promise_test(t => {
|
||||
return new Promise(resolve => {
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.onload = t.step_func(() => {
|
||||
resolve(testSharingViaIncrementerScript(t, window, "window", iframe.contentWindow, "iframe", "*"));
|
||||
});
|
||||
iframe.src = "//{{domains[www1]}}:{{location[port]}}/wasm/serialization/resources/incrementer-iframe-domain.sub.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
}, "postMessaging to a same-origin-domain (but not same-origin) iframe allows them to instantiate");
|
||||
|
||||
</script>
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<meta charset="utf-8">
|
||||
<title>Structured cloning of WebAssembly.Module using MessageChannel</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/test-incrementer.js"></script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
promise_test(t => {
|
||||
const worker = new Worker("resources/incrementer-worker-with-channel.js");
|
||||
const channel = new MessageChannel();
|
||||
worker.postMessage(channel.port2, [channel.port2]);
|
||||
|
||||
return testSharingViaIncrementerScript(t, channel.port1, "window", channel.port1, "worker");
|
||||
}, "postMessaging to a dedicated worker via MessageChannel allows them to instantiate");
|
||||
</script>
|
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<title>WebAssembly.Module cannot cross agent clusters, service worker edition</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
|
||||
<script src="./resources/create-empty-wasm-module.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
promise_test(t => {
|
||||
const scope = "resources/blank.html";
|
||||
return service_worker_unregister_and_register(t, "resources/serviceworker-failure.js", scope).then(reg => {
|
||||
return wait_for_state(t, reg.installing, "activated");
|
||||
})
|
||||
.then(() => {
|
||||
return with_iframe(scope);
|
||||
}).then(iframe => {
|
||||
const sw = iframe.contentWindow.navigator.serviceWorker;
|
||||
let state = "start in window";
|
||||
|
||||
return new Promise(resolve => {
|
||||
sw.onmessage = t.step_func(e => {
|
||||
if (e.data === "start in worker") {
|
||||
assert_equals(state, "start in window");
|
||||
sw.controller.postMessage(createEmptyWasmModule());
|
||||
state = "we are expecting confirmation of an onmessageerror in the worker";
|
||||
} else if (e.data === "onmessageerror was received in worker") {
|
||||
assert_equals(state, "we are expecting confirmation of an onmessageerror in the worker");
|
||||
state = "we are expecting a messageerror due to the worker sending us a WebAssembly.Module";
|
||||
sw.controller.postMessage(state);
|
||||
} else {
|
||||
assert_unreached("Got an unexpected message from the service worker: " + e.data);
|
||||
}
|
||||
});
|
||||
|
||||
sw.onmessageerror = t.step_func(e => {
|
||||
assert_equals(state, "we are expecting a messageerror due to the worker sending us a WebAssembly.Module");
|
||||
|
||||
assert_equals(e.data, null, "data");
|
||||
assert_equals(e.origin, self.origin, "origin");
|
||||
assert_equals(e.source, null, "source");
|
||||
assert_equals(e.ports.length, 0, "ports length");
|
||||
|
||||
state = "done in window";
|
||||
resolve();
|
||||
});
|
||||
|
||||
sw.controller.postMessage(state);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,33 @@
|
|||
<!doctype html>
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<title>WebAssembly.Modules cannot cross agent clusters, shared worker edition</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/create-empty-wasm-module.js"></script>
|
||||
<script>
|
||||
async_test(t => {
|
||||
const sw = new SharedWorker("resources/sharedworker-failure.js")
|
||||
let state = ""
|
||||
sw.port.onmessage = t.step_func(e => {
|
||||
if(e.data === "send-sw-failure") {
|
||||
sw.port.postMessage(createEmptyWasmModule())
|
||||
} else if(e.data === "send-sw-failure-success") {
|
||||
state = "send-window-failure"
|
||||
sw.port.postMessage(state)
|
||||
} else {
|
||||
assert_unreached()
|
||||
}
|
||||
})
|
||||
sw.port.onmessageerror = t.step_func(e => {
|
||||
if(state === "send-window-failure") {
|
||||
assert_equals(e.data, null, "data")
|
||||
assert_equals(e.origin, "", "origin")
|
||||
assert_equals(e.source, null, "source")
|
||||
assert_equals(e.ports.length, 0, "ports length")
|
||||
t.done()
|
||||
} else {
|
||||
assert_unreached()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<meta charset="utf-8">
|
||||
<title>Structured cloning of WebAssembly.Module to similar-origin, but not same-origin, windows</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/test-incrementer.js"></script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
document.domain = "{{host}}";
|
||||
|
||||
promise_test(t => {
|
||||
return new Promise(resolve => {
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.onload = t.step_func(() => {
|
||||
resolve(testSharingViaIncrementerScript(t, window, "window", iframe.contentWindow, "iframe", "*"));
|
||||
});
|
||||
iframe.src = "//{{domains[www1]}}:{{location[port]}}/wasm/serialization/resources/incrementer-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
}, "postMessaging to a not same-origin-domain, but similar origin, iframe allows them to instantiate");
|
||||
</script>
|
|
@ -0,0 +1,57 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Based on similar tests in html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/ -->
|
||||
<meta charset="utf-8">
|
||||
<title>Structured cloning of WebAssembly.Module: simple success cases that don't need dedicated files</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="./resources/test-incrementer.js"></script>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
promise_test(t => {
|
||||
const worker = new Worker("resources/incrementer-worker.js");
|
||||
|
||||
return testSharingViaIncrementerScript(t, worker, "window", worker, "worker", undefined);
|
||||
}, "postMessaging to a dedicated worker allows them to instantiate");
|
||||
|
||||
promise_test(t => {
|
||||
return new Promise(resolve => {
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.onload = t.step_func(() => {
|
||||
resolve(testSharingViaIncrementerScript(t, window, "window", iframe.contentWindow, "iframe", "*"));
|
||||
});
|
||||
iframe.src = "resources/incrementer-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
}, "postMessaging to a same-origin iframe allows them to instantiate");
|
||||
|
||||
promise_test(t => {
|
||||
return new Promise(resolve => {
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.onload = t.step_func(() => {
|
||||
const level1 = iframe.contentWindow;
|
||||
const level2 = level1.frames[0];
|
||||
const level3 = level2.frames[0];
|
||||
const targetWindow = level3.frames[0];
|
||||
resolve(testSharingViaIncrementerScript(t, window, "window", targetWindow, "nested iframe", "*"));
|
||||
});
|
||||
iframe.src = "resources/nested-iframe-1.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
}, "postMessaging to a same-origin deeply-nested iframe allows them to instantiate");
|
||||
|
||||
promise_test(t => {
|
||||
return new Promise(resolve => {
|
||||
const w = window.open("resources/incrementer-popup.html");
|
||||
w.onload = t.step_func(() => {
|
||||
resolve(testSharingViaIncrementerScript(t, window, "window", w, "popup window", "*").then(() => {
|
||||
w.close();
|
||||
}));
|
||||
});
|
||||
});
|
||||
}, "postMessaging to a same-origin opened window allows them to instantiate");
|
||||
|
||||
</script>
|
|
@ -1,19 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/load_wasm.js"></script>
|
||||
<script>
|
||||
function runTests(iframe) {
|
||||
iframe = iframe.contentWindow;
|
||||
promise_test(async function() {
|
||||
var mod = await createWasmModule();
|
||||
assert_true(mod instanceof WebAssembly.Module);
|
||||
var ans = await new Promise((resolve, reject) => {
|
||||
iframe.postMessage(mod, '*');
|
||||
window.addEventListener("message", (reply) => resolve(reply.data), false);
|
||||
});
|
||||
assert_equals(ans, 43);
|
||||
}, "send wasm module to iframe");
|
||||
}
|
||||
</script>
|
||||
<iframe src="resources/frame.html" onload="runTests(this)"></iframe>
|
|
@ -1,8 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/load_wasm.js"></script>
|
||||
<script src="wasm_serialization_tests.js"></script>
|
||||
<script>
|
||||
promise_test(TestInstantiateInWorker, "serialize wasm to worker");
|
||||
</script>
|
|
@ -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));
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Service Worker: postMessage with wasm</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
promise_test(async test => {
|
||||
var registration = await service_worker_unregister_and_register(
|
||||
test, 'resources/service-worker.js', 'resources/blank.html');
|
||||
add_completion_callback(() => registration.unregister());
|
||||
var worker = registration.installing;
|
||||
var event = await new Promise((resolve, reject) => {
|
||||
var messageChannel = new MessageChannel();
|
||||
worker.postMessage({port: messageChannel.port2}, [messageChannel.port2]);
|
||||
worker.postMessage({compile: true});
|
||||
messageChannel.port1.onmessage = event => reject(event);
|
||||
messageChannel.port1.onmessageerror = event => resolve(event);
|
||||
});
|
||||
assert_equals(event.type, "messageerror");
|
||||
assert_equals(event.data, null);
|
||||
}, 'postMessaging wasm from a service worker should fail');
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче