tor-browser

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

Debugger-findScripts-07.js (1062B)


      1 // findScripts can filter scripts by global.
      2 var g1 = newGlobal({newCompartment: true});
      3 var g2 = newGlobal({newCompartment: true});
      4 var g3 = newGlobal({newCompartment: true});
      5 
      6 var dbg = new Debugger();
      7 var g1w = dbg.addDebuggee(g1);
      8 var g2w = dbg.addDebuggee(g2);
      9 
     10 g1.eval('function f() {}');
     11 g2.eval('function g() {}');
     12 g2.eval('function h() {}');
     13 var g1fw = g1w.makeDebuggeeValue(g1.f);
     14 var g2gw = g2w.makeDebuggeeValue(g2.g);
     15 
     16 var scripts;
     17 
     18 scripts = dbg.findScripts({});
     19 assertEq(scripts.indexOf(g1fw.script) != -1, true);
     20 assertEq(scripts.indexOf(g2gw.script) != -1, true);
     21 
     22 scripts = dbg.findScripts({global: g1});
     23 assertEq(scripts.indexOf(g1fw.script) != -1, true);
     24 assertEq(scripts.indexOf(g2gw.script) != -1, false);
     25 
     26 scripts = dbg.findScripts({global: g2});
     27 assertEq(scripts.indexOf(g1fw.script) != -1, false);
     28 assertEq(scripts.indexOf(g2gw.script) != -1, true);
     29 
     30 scripts = dbg.findScripts({global: g3});
     31 // findScripts should only return debuggee scripts, and g3 isn't a
     32 // debuggee, so this should be completely empty.
     33 assertEq(scripts.length, 0);