summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Script-isFunction.js
blob: 5f68d54b19edc9d96e9a786602a1863b1cfdf13c (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
// Script.isFunction should do what it is supposed to do.

const g = newGlobal({newCompartment: true});
const dbg = new Debugger;
dbg.addDebuggee(g);

let gNumFunctionScripts = 0;
function countFunctionScripts(script) {
  if (script.isFunction) {
    gNumFunctionScripts++;
  }
  return script.getChildScripts().forEach(countFunctionScripts);
}

dbg.onNewScript = countFunctionScripts;

g.eval(`
function f() {
  function f2() {}
}
async function g() {}
function* h() {}
`);

assertEq(gNumFunctionScripts, 4);