tor-browser

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

testEarlyReturnOnCall.js (682B)


      1 var g = newGlobal({newCompartment: true});
      2 g.eval("var success = false");
      3 g.eval("function ponies() {}");
      4 g.eval("function foo() { ponies(); success = false }");
      5 
      6 var dbg = new Debugger(g);
      7 dbg.onEnterFrame = function(frame) {
      8    // The goal here is force an early return on the 'call' instruction,
      9    // which should be the 3rd step (callgname, undefined, call)
     10    var step = 0;
     11    frame.onStep = function() {
     12        ++step;
     13        if (step == 2) {
     14            g.success = true;
     15            return;
     16        }
     17        if (step == 3)
     18            return { return: undefined }
     19    }
     20    frame.onPop = function() { new Error(); /* boom */ }
     21 }
     22 
     23 g.foo();
     24 assertEq(g.success, true);