summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/breakpoint-await.js
blob: 9a648cab01d3544d8866ad468d1cf7d7986ec910 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
if (typeof disassemble !== "function") {
  quit();
}

const g = newGlobal({ newCompartment: true });
g.eval(`
async function func() {
  await 10;
}
async function * func2() {
  await 10;
}
var func_dis = disassemble(func);
var func2_dis = disassemble(func2);
`);
const d = new Debugger();
const dg = d.addDebuggee(g);
const script = dg.makeDebuggeeValue(g.func).script;
const script2 = dg.makeDebuggeeValue(g.func2).script;

function getOffsets(code) {
  let CanSkipAwait_offset = -1;
  let Await_offset = -1;
  let m;
  for (const line of code.split("\n")) {
    m = line.match(/(\d+):\s+\d+\s+CanSkipAwait\s/);
    if (m) {
      CanSkipAwait_offset = parseInt(m[1], 10);
    }

    m = line.match(/(\d+):\s+\d+\s+Await\s/);
    if (m) {
      Await_offset = parseInt(m[1], 10);
    }
  }
  assertEq(CanSkipAwait_offset !== -1, true);
  assertEq(Await_offset !== -1, true);
  return [CanSkipAwait_offset, Await_offset];
}

let [CanSkipAwait_offset, Await_offset] = getOffsets(g.func_dis);
assertEq(script.getEffectfulOffsets().includes(CanSkipAwait_offset), true);
assertEq(script.getEffectfulOffsets().includes(Await_offset), true);

[CanSkipAwait_offset, Await_offset] = getOffsets(g.func2_dis);
assertEq(script2.getEffectfulOffsets().includes(CanSkipAwait_offset), true);
assertEq(script2.getEffectfulOffsets().includes(Await_offset), true);