test_promise.html (1826B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test for promise in worklet</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 7 <script type="application/javascript" src="common.js"></script> 8 </head> 9 <body> 10 11 <script type="application/javascript"> 12 async function runTestInIframe() { 13 if (!SpecialPowers.Cu.getJSTestingFunctions().wasmIsSupported()) { 14 SimpleTest.finish(); 15 return; 16 } 17 18 // Log to test that JS::SetWarningReporter() setup is done for bug 1898684. 19 await SpecialPowers.pushPrefEnv( 20 {"set": [["javascript.options.wasm_verbose", true]]}); 21 22 ok(window.isSecureContext, "Test should run in secure context"); 23 var audioContext = new AudioContext(); 24 ok(audioContext.audioWorklet instanceof AudioWorklet, 25 "AudioContext.audioWorklet should be an instance of AudioWorklet"); 26 audioContext.audioWorklet.addModule("worklet_promise.js") 27 .then(() => { 28 const node = new AudioWorkletNode(audioContext, 'promise'); 29 node.port.onmessage = e => { 30 ok(e.data instanceof WebAssembly.Module, "The WasmModule has been compiled into the worklet."); 31 SimpleTest.finish(); 32 } 33 34 // eslint-disable-next-line no-unused-vars 35 const wasmTextToBinary = SpecialPowers.unwrap(SpecialPowers.Cu.getJSTestingFunctions().wasmTextToBinary); 36 /* 37 js -e ' 38 t = wasmTextToBinary(` 39 (module 40 (func $foo (result i32) (i32.const 42)) 41 (export "foo" (func $foo)) 42 ) 43 `); 44 print(t) 45 ' 46 */ 47 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]); 48 49 node.port.postMessage(fooModuleCode); 50 }); 51 } 52 </script> 53 </body> 54 </html>