tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Script-isFunction.js (510B)


      1 // Script.isFunction should do what it is supposed to do.
      2 
      3 const g = newGlobal({newCompartment: true});
      4 const dbg = new Debugger;
      5 dbg.addDebuggee(g);
      6 
      7 let gNumFunctionScripts = 0;
      8 function countFunctionScripts(script) {
      9  if (script.isFunction) {
     10    gNumFunctionScripts++;
     11  }
     12  return script.getChildScripts().forEach(countFunctionScripts);
     13 }
     14 
     15 dbg.onNewScript = countFunctionScripts;
     16 
     17 g.eval(`
     18 function f() {
     19  function f2() {}
     20 }
     21 async function g() {}
     22 function* h() {}
     23 `);
     24 
     25 assertEq(gNumFunctionScripts, 4);