summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/regress/bug1502886.js
blob: a45bf774a45af969d1d500ab7df0edc6bdeb1384 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
newGlobal({newCompartment: true});
g = newGlobal({newCompartment: true});
var dbg = Debugger(g);
gczeal(2, 100);
function f(x, initFunc) {
    newGlobal({newCompartment: true});
    g.eval(`
        var binary = wasmTextToBinary('${x}');
        new WebAssembly.Instance(new WebAssembly.Module(binary));
    `);
    var wasmScript = dbg.findScripts().filter(s => s.format == 'wasm')[0];
    var offsets = wasmScript.getPossibleBreakpointOffsets();
    initFunc({
        wasmScript,
        breakpoints: offsets
    })
};
try {
    f('(module (func nop nop) (export "" (func 0)))',
        function({
            wasmScript,
            breakpoints
        }) {
            breakpoints.forEach(function(offset) {
                wasmScript.setBreakpoint(offset, s = {});
            });
        }
    );
    f();
} catch (e) {}