diff options
Diffstat (limited to 'js/src/jit-test/tests/wasm/js-promise-integration/multi.js')
-rw-r--r-- | js/src/jit-test/tests/wasm/js-promise-integration/multi.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/js-promise-integration/multi.js b/js/src/jit-test/tests/wasm/js-promise-integration/multi.js new file mode 100644 index 0000000000..7713637642 --- /dev/null +++ b/js/src/jit-test/tests/wasm/js-promise-integration/multi.js @@ -0,0 +1,36 @@ +// Multiple promises at the same time. + +function js_import() { + return Promise.resolve(42); +} +var wasm_js_import = new WebAssembly.Function( + { parameters: ['externref'], results: ['i32'] }, + js_import, + { suspending: 'first' }); + +var ins = wasmEvalText(`(module + (import "m" "import" (func $f (param externref) (result i32))) + (func (export "test") (param externref) (result i32) + local.get 0 + call $f + ) +)`, {"m": {import: wasm_js_import}}); + +let wrapped_export = new WebAssembly.Function( + { + parameters: [], + results: ['externref'] + }, + ins.exports.test, { promising: 'first' }); + +Promise.resolve().then(() => { + wrapped_export().then(i => { + assertEq(42, i) + }); +}); + +Promise.resolve().then(() => { + wrapped_export().then(i => { + assertEq(42, i) + }); +}); |