js/src/jit-test/tests/debug/Environment-callee-01.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Debugger.Environment.prototype.callee reveals the callee of environments
     2 // that have them.
     4 var g = newGlobal();
     5 var dbg = new Debugger;
     6 var gw = dbg.addDebuggee(g);
     8 function check(code, expectedType, expectedCallee) {
     9   print("check(" + uneval(code) + ")");
    10   var hits;
    11   dbg.onDebuggerStatement = function (frame) {
    12     hits++;
    13     var env = frame.environment;
    14     assertEq(env.type, expectedType);
    15     assertEq(env.callee, expectedCallee);
    16   };
    17   hits = 0;
    18   g.eval(code);
    19   assertEq(hits, 1);
    20 }
    22 check('debugger;', 'object', null);
    23 check('with({}) { debugger; };', 'with', null);
    24 check('let (x=1) { debugger; };', 'declarative', null);
    26 g.eval('function f() { debugger; }');
    27 check('f()', 'declarative', gw.makeDebuggeeValue(g.f));
    29 g.eval('function g() { h(); }');
    30 g.eval('function h() { debugger; }');
    31 check('g()', 'declarative', gw.makeDebuggeeValue(g.h));
    33 // Strict direct eval gets its own environment.
    34 check('"use strict"; eval("debugger");', 'declarative', null);
    35 g.eval('function j() { "use strict"; eval("debugger;"); }');
    36 check('j()', 'declarative', null);
    38 // Lenient direct eval shares eval's caller's environment,
    39 // although this is a great evil.
    40 check('eval("debugger");', 'object', null);
    41 g.eval('function k() { eval("debugger;"); }');
    42 check('k()', 'declarative', gw.makeDebuggeeValue(g.k));
    44 g.eval('function m() { debugger; yield true; }');
    45 check('m().next();', 'declarative', gw.makeDebuggeeValue(g.m));
    47 g.eval('function n() { let (x = 1) { debugger; } }');
    48 check('n()', 'declarative', null);
    50 g.eval('function* o() { debugger; yield true; }');
    51 check('o().next();', 'declarative', gw.makeDebuggeeValue(g.o));

mercurial