зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1611855 - Worklet must be part of the same parent's agentCluster - part 5 - more tests, r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D61187 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3ea0389cd5
Коммит
5ee8116920
|
@ -47,8 +47,15 @@ function create_wasmModule() {
|
|||
});
|
||||
}
|
||||
|
||||
function test_simple() {
|
||||
info("BroadcastChannel");
|
||||
function enable_sab() {
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{"set": [
|
||||
["dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled", true],
|
||||
]}, next);
|
||||
}
|
||||
|
||||
function test_wasm() {
|
||||
info("BroadcastChannel + WASM");
|
||||
|
||||
if (!wasmModule) {
|
||||
next();
|
||||
|
@ -68,8 +75,8 @@ function test_simple() {
|
|||
bc2.close();
|
||||
}
|
||||
|
||||
function test_worker() {
|
||||
info("BroadcastChannel in workers");
|
||||
function test_wasm_worker() {
|
||||
info("BroadcastChannel + WASM in workers");
|
||||
|
||||
if (!wasmModule) {
|
||||
next();
|
||||
|
@ -92,10 +99,50 @@ function test_worker() {
|
|||
new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
function test_sab() {
|
||||
info("BroadcastChannel + SAB");
|
||||
|
||||
const bc1 = new BroadcastChannel('a');
|
||||
const bc2 = new BroadcastChannel('a');
|
||||
|
||||
bc1.onmessage = e => {
|
||||
ok(e.data.sab instanceof SharedArrayBuffer, "SAB received");
|
||||
bc1.close();
|
||||
next();
|
||||
};
|
||||
|
||||
bc2.postMessage({sab: new SharedArrayBuffer(1024)});
|
||||
bc2.close();
|
||||
}
|
||||
|
||||
function test_sab_worker() {
|
||||
info("BroadcastChannel + WASM in workers");
|
||||
|
||||
const bc = new BroadcastChannel('b');
|
||||
bc.onmessage = e => {
|
||||
if (e.data === "ready") {
|
||||
bc.postMessage({sab: new SharedArrayBuffer(1024)});
|
||||
return;
|
||||
}
|
||||
|
||||
ok(e.data.sab instanceof SharedArrayBuffer, "SAB received");
|
||||
bc.close();
|
||||
next();
|
||||
};
|
||||
|
||||
const blob = new Blob([document.getElementById('myWorker').textContent]);
|
||||
new Worker(URL.createObjectURL(blob));
|
||||
}
|
||||
|
||||
const tests = [
|
||||
enable_sab,
|
||||
create_wasmModule,
|
||||
test_simple,
|
||||
test_worker,
|
||||
|
||||
test_wasm,
|
||||
test_wasm_worker,
|
||||
|
||||
test_sab,
|
||||
test_sab_worker,
|
||||
];
|
||||
|
||||
function next() {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<script id='myWorker' type='text/worker'>
|
||||
self.onmessage = e => {
|
||||
e.ports[0].onmessage = ee => postMessage(ee.data);
|
||||
e.ports[0].onmessage = ee => e.ports[0].postMessage(ee.data);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -44,8 +44,15 @@ function create_wasmModule() {
|
|||
});
|
||||
}
|
||||
|
||||
function test_simple() {
|
||||
info("MessagePort without disentangling");
|
||||
function enable_sab() {
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{"set": [
|
||||
["dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled", true],
|
||||
]}, next);
|
||||
}
|
||||
|
||||
function test_wasm() {
|
||||
info("MessagePort + WASM without disentangling");
|
||||
|
||||
if (!wasmModule) {
|
||||
next();
|
||||
|
@ -60,8 +67,8 @@ function test_simple() {
|
|||
};
|
||||
}
|
||||
|
||||
function test_worker() {
|
||||
info("MessagePort sent to a worker");
|
||||
function test_wasm_worker() {
|
||||
info("MessagePort + WASM sent to a worker");
|
||||
|
||||
if (!wasmModule) {
|
||||
next();
|
||||
|
@ -70,21 +77,48 @@ function test_worker() {
|
|||
|
||||
const mc = new MessageChannel();
|
||||
mc.port1.postMessage({ wasmModule });
|
||||
mc.port1.onmessage = e => {
|
||||
ok(e.data.wasmModule instanceof WebAssembly.Module, "WasmModule received");
|
||||
next();
|
||||
};
|
||||
|
||||
const blob = new Blob([document.getElementById('myWorker').textContent]);
|
||||
const w = new Worker(URL.createObjectURL(blob));
|
||||
w.postMessage(42, [ mc.port2 ]);
|
||||
w.onmessage = e => {
|
||||
ok(e.data.wasmModule instanceof WebAssembly.Module, "WasmModule received");
|
||||
}
|
||||
|
||||
function test_sab() {
|
||||
info("MessagePort + SAB without disentangling");
|
||||
|
||||
const mc = new MessageChannel();
|
||||
mc.port1.postMessage({sab: new SharedArrayBuffer(1024)});
|
||||
mc.port2.onmessage = e => {
|
||||
ok(e.data.sab instanceof SharedArrayBuffer, "SAB received");
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function test_sab_worker() {
|
||||
info("MessagePort + SAB sent to a worker");
|
||||
|
||||
const mc = new MessageChannel();
|
||||
mc.port1.postMessage({sab: new SharedArrayBuffer(1024)});
|
||||
mc.port1.onmessage = e => {
|
||||
ok(e.data.sab instanceof SharedArrayBuffer, "SAB received");
|
||||
next();
|
||||
};
|
||||
|
||||
const blob = new Blob([document.getElementById('myWorker').textContent]);
|
||||
const w = new Worker(URL.createObjectURL(blob));
|
||||
w.postMessage(42, [ mc.port2 ]);
|
||||
}
|
||||
|
||||
const tests = [
|
||||
enable_sab,
|
||||
create_wasmModule,
|
||||
|
||||
test_simple,
|
||||
test_worker,
|
||||
test_wasm,
|
||||
test_wasm_worker,
|
||||
];
|
||||
|
||||
function next() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче