зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1611855 - Worklet must be part of the same parent's agentCluster - part 4 - tests, r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D61137 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
94658a20fe
Коммит
f8ed0cd543
|
@ -23,3 +23,5 @@ support-files=worklet_exception.js
|
|||
[test_paintWorklet.html]
|
||||
scheme = http
|
||||
support-files=worklet_paintWorklet.js
|
||||
[test_audioWorklet_WASM.html]
|
||||
support-files=worklet_audioWorklet_WASM.js
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for AudioWorklet + WASM</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript" src="common.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
function configureTest() {
|
||||
return SpecialPowers.pushPrefEnv(
|
||||
{"set": [["dom.audioworklet.enabled", true],
|
||||
["dom.worklet.enabled", true],
|
||||
["dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled", true],
|
||||
]});
|
||||
}
|
||||
|
||||
function create_wasmModule() {
|
||||
return new Promise(resolve => {
|
||||
info("Checking if we can play with WebAssembly...");
|
||||
|
||||
if (!SpecialPowers.Cu.getJSTestingFunctions().wasmIsSupported()) {
|
||||
resolve(null);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(WebAssembly, "WebAssembly object should exist");
|
||||
ok(WebAssembly.compile, "WebAssembly.compile function should exist");
|
||||
|
||||
const wasmTextToBinary = SpecialPowers.unwrap(SpecialPowers.Cu.getJSTestingFunctions().wasmTextToBinary);
|
||||
const fooModuleCode = wasmTextToBinary(`(module
|
||||
(func $foo (result i32) (i32.const 42))
|
||||
(export "foo" $foo)
|
||||
)`);
|
||||
|
||||
WebAssembly.compile(fooModuleCode).then(m => {
|
||||
ok(m instanceof WebAssembly.Module, "The WasmModule has been compiled.");
|
||||
resolve(m);
|
||||
}, () => {
|
||||
ok(false, "The compilation of the wasmModule failed.");
|
||||
resolve(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function runTestInIframe() {
|
||||
let audioContext = new AudioContext();
|
||||
audioContext.audioWorklet.addModule("worklet_audioWorklet_WASM.js")
|
||||
.then(() => create_wasmModule())
|
||||
.then(wasmModule => {
|
||||
const node = new AudioWorkletNode(audioContext, 'wasm');
|
||||
let msgId = 0;
|
||||
node.port.onmessage = e => {
|
||||
if (msgId++ == 0) {
|
||||
ok(e.data.wasmModule instanceof WebAssembly.Module, "WasmModule received");
|
||||
} else {
|
||||
ok(e.data.sab instanceof SharedArrayBuffer, "SAB received");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
node.port.postMessage({wasmModule});
|
||||
node.port.postMessage({sab: new SharedArrayBuffer(1024)});
|
||||
node.connect(audioContext.destination);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
class WasmProcessWorkletProcessor extends AudioWorkletProcessor {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
this.port.onmessage = e => {
|
||||
// Let's send it back.
|
||||
this.port.postMessage(e.data);
|
||||
};
|
||||
}
|
||||
|
||||
process(inputs, outputs, parameters) {
|
||||
// Do nothing, output silence
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor("wasm", WasmProcessWorkletProcessor);
|
Загрузка…
Ссылка в новой задаче