diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/worklet/tests/test_promise.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/worklet/tests/test_promise.html')
-rw-r--r-- | dom/worklet/tests/test_promise.html | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/dom/worklet/tests/test_promise.html b/dom/worklet/tests/test_promise.html new file mode 100644 index 0000000000..5b438ddcc2 --- /dev/null +++ b/dom/worklet/tests/test_promise.html @@ -0,0 +1,50 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test for promise in worklet</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 runTestInIframe() { + if (!SpecialPowers.Cu.getJSTestingFunctions().wasmIsSupported()) { + SimpleTest.finish(); + return; + } + + ok(window.isSecureContext, "Test should run in secure context"); + var audioContext = new AudioContext(); + ok(audioContext.audioWorklet instanceof AudioWorklet, + "AudioContext.audioWorklet should be an instance of AudioWorklet"); + audioContext.audioWorklet.addModule("worklet_promise.js") + .then(() => { + const node = new AudioWorkletNode(audioContext, 'promise'); + node.port.onmessage = e => { + ok(e.data instanceof WebAssembly.Module, "The WasmModule has been compiled into the worklet."); + SimpleTest.finish(); + } + + const wasmTextToBinary = SpecialPowers.unwrap(SpecialPowers.Cu.getJSTestingFunctions().wasmTextToBinary); + /* + js -e ' + t = wasmTextToBinary(` + (module + (func $foo (result i32) (i32.const 42)) + (export "foo" (func $foo)) + ) + `); + print(t) + ' + */ + // eslint-disable-next-line + const fooModuleCode = new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,127,3,2,1,0,7,7,1,3,102,111,111,0,0,10,6,1,4,0,65,42,11,0,13,4,110,97,109,101,1,6,1,0,3,102,111,111]); + + node.port.postMessage(fooModuleCode); + }); +} +</script> +</body> +</html> |