summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/wasm-09.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/debug/wasm-09.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/debug/wasm-09.js')
-rw-r--r--js/src/jit-test/tests/debug/wasm-09.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/wasm-09.js b/js/src/jit-test/tests/debug/wasm-09.js
new file mode 100644
index 0000000000..c01a696d0a
--- /dev/null
+++ b/js/src/jit-test/tests/debug/wasm-09.js
@@ -0,0 +1,32 @@
+// |jit-test| test-also=--wasm-compiler=optimizing; skip-if: !wasmDebuggingEnabled()
+// Tests debugEnabled state of wasm when allowUnobservedWasm == true.
+
+load(libdir + "asserts.js");
+
+// Checking that there are no offsets are present in a wasm instance script for
+// which debug mode was not enabled.
+function getWasmScriptWithoutAllowUnobservedWasm(wast) {
+ var sandbox = newGlobal({newCompartment: true});
+ var dbg = new Debugger();
+ dbg.allowUnobservedWasm = true;
+ dbg.addDebuggee(sandbox);
+ sandbox.eval(`
+ var wasm = wasmTextToBinary('${wast}');
+ var m = new WebAssembly.Instance(new WebAssembly.Module(wasm));
+ `);
+ // Attaching after wasm instance is created.
+ var wasmScript = dbg.findScripts().filter(s => s.format == 'wasm')[0];
+ return wasmScript;
+}
+
+var wasmScript1 = getWasmScriptWithoutAllowUnobservedWasm('(module (func (nop)))');
+var wasmLines1 = wasmScript1.source.text.split('\n');
+assertEq(wasmScript1.startLine, 1);
+assertEq(wasmScript1.lineCount, 0);
+assertEq(wasmLines1.every((l, n) => wasmScript1.getLineOffsets(n + 1).length == 0), true);
+
+// Checking that we must not resolve any location for any offset in a wasm
+// instance which debug mode was not enabled.
+var wasmScript2 = getWasmScriptWithoutAllowUnobservedWasm('(module (func (nop)))');
+for (var i = wasmTextToBinary('(module (func (nop)))').length - 1; i >= 0; i--)
+ assertThrowsInstanceOf(() => wasmScript2.getOffsetLocation(i), Error);