diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/wasm/directiveless/bug1645310.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/wasm/directiveless/bug1645310.js')
-rw-r--r-- | js/src/jit-test/tests/wasm/directiveless/bug1645310.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/directiveless/bug1645310.js b/js/src/jit-test/tests/wasm/directiveless/bug1645310.js new file mode 100644 index 0000000000..3532886c6a --- /dev/null +++ b/js/src/jit-test/tests/wasm/directiveless/bug1645310.js @@ -0,0 +1,61 @@ +// |jit-test| --wasm-compiler=optimizing; skip-if: !wasmIsSupported() + +// In this case we're setting things up so that wasm can't be compiled, as the +// only available compiler is Ion, and enabling the Debugger will disable Ion. +// +// The test tests that the lazy creation of the WebAssembly object is not +// dependent on whether WebAssembly can be compiled or not: if wasm is supported +// then the WebAssembly object should always be created. The fact that wasm +// can't be compiled is a separate matter. +// +// IT'S IMPORTANT NOT TO MENTION THE WEBASSEMBLY OBJECT UNTIL AFTER THE DEBUGGER +// HAS BEEN CREATED, AND NOT TO LOAD lib/wasm.js OR OTHER WASM CODE HERE. + +var g7 = newGlobal({newCompartment: true}); +g7.parent = this; +g7.eval("var dbg = Debugger(parent)"); +assertEq(typeof WebAssembly, "object"); + +// Test that validation works even if compilers are not available. + +WebAssembly.validate(wasmTextToBinary('(module (func))')); + +// Test that compilation fails with a sensible error. + +var bits = wasmTextToBinary('(module (func))'); +var msg = /no WebAssembly compiler available/ +var exn; + +exn = null; +try { new WebAssembly.Module(bits); } catch (e) { exn = e; } +assertEq(Boolean(exn), true); +assertEq(Boolean(String(exn).match(msg)), true); + +exn = null; +try { WebAssembly.compile(bits); } catch (e) { exn = e; } +assertEq(Boolean(exn), true); +assertEq(Boolean(String(exn).match(msg)), true); + +exn = null; +try { WebAssembly.instantiate(bits); } catch (e) { exn = e; } +assertEq(Boolean(exn), true); +assertEq(Boolean(String(exn).match(msg)), true); + +// We do not use wasmStreamingEnabled() here because that checks whether +// compilers are available, and that is precisely what we want to be checking +// ourselves. But streaming compilation is available only if there are helper +// threads, so that's an OK proxy. + +if (helperThreadCount() > 0) { + exn = null; + WebAssembly.compileStreaming(bits).catch(e => { exn = e; }); + drainJobQueue(); + assertEq(Boolean(exn), true); + assertEq(Boolean(String(exn).match(msg)), true); + + exn = null; + WebAssembly.instantiateStreaming(bits).catch(e => { exn = e; }); + drainJobQueue(); + assertEq(Boolean(exn), true); + assertEq(Boolean(String(exn).match(msg)), true); +} |