tor-browser

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

Frame-this-04.js (706B)


      1 // Debugger.Frame.prototype.this in functions, with object values
      2 
      3 function classOf(obj) {
      4    return Object.prototype.toString.call(obj).match(/^\[object (.*)\]$/)[1];
      5 }
      6 
      7 var g = newGlobal({newCompartment: true});
      8 var dbg = new Debugger(g);
      9 var hits = 0;
     10 dbg.onDebuggerStatement = function (frame) {
     11    hits++;
     12    assertEq(frame.this instanceof Debugger.Object, true);
     13    assertEq(frame.this.class, classOf(Object(g.v)));
     14 };
     15 
     16 g.eval("function f() { debugger; }");
     17 
     18 g.eval("v = {}; f.call(v);");
     19 g.eval("v.f = f; v.f();");
     20 g.eval("v = new Date; f.call(v);");
     21 g.eval("v.f = f; v.f();");
     22 g.eval("v = []; f.call(v);");
     23 g.eval("Object.prototype.f = f; v.f();");
     24 g.eval("v = this; f();");
     25 assertEq(hits, 7);