tor-browser

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

onEnterFrame-01.js (729B)


      1 // Basic enterFrame hook tests.
      2 
      3 var g = newGlobal({newCompartment: true});
      4 var dbg = Debugger(g);
      5 var type;
      6 dbg.onEnterFrame = function (frame) {
      7    try {
      8        assertEq(frame instanceof Debugger.Frame, true);
      9        assertEq(frame.onStack, true);
     10        type = frame.type;
     11    } catch (exc) {
     12        type = "Exception thrown: " + exc;
     13    }
     14 };
     15 
     16 function test(f, expected) {
     17    type = undefined;
     18    f();
     19    assertEq(type, expected);
     20 }
     21 
     22 // eval triggers the hook
     23 test(function () { g.eval("function h() { return 1; }"); }, "eval");
     24 
     25 // function calls trigger it
     26 test(function () { assertEq(g.h(), 1); }, "call");
     27 
     28 // global scripts trigger it
     29 test(function () { g.evaluate("var x = 5;"); assertEq(g.x, 5); }, "global");