js/src/jit-test/tests/debug/Script-staticLevel.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.Script.prototype.staticLevel returns the script's static level.
     2 load(libdir + 'asserts.js');
     4 var g = newGlobal();
     5 var dbg = Debugger();
     6 var gw = dbg.addDebuggee(g);
     8 function test(expr, level) {
     9     var log;
    10     dbg.onDebuggerStatement = function (frame) {
    11         log += 'd';
    12         assertEq(frame.script.staticLevel, level);
    13     };
    15     print("Testing: " + expr);
    17     log = '';
    18     // The shell's 'evaluate' runs its argument as global code.
    19     g.evaluate(expr);
    20     assertEq(log, 'd');
    21 }
    24 test("debugger;", 0);
    25 test("(function () { debugger; })()", 1);
    26 test("(function () { (function () { debugger; })(); })()", 2);
    27 test("(function () { (function () { (function () { debugger; })(); })(); })()", 3);
    29 test("eval('debugger;');", 1);
    30 test("eval('eval(\\\'debugger;\\\');');", 2);
    31 test("evil = eval; eval('evil(\\\'debugger;\\\');');", 0); // I don't think it's evil at all!
    32 test("(function () { eval('debugger;'); })();", 2);
    33 test("evil = eval; (function () { evil('debugger;'); })();", 0);
    35 // Generators' expressions are within a synthesized function's body.
    36 test("((function () { debugger; })() for (x in [1])).next();", 2);
    37 test("(x for (x in ((function () { debugger; })(), [1]))).next();", 2);
    39 // The staticLevel accessor can't be assigned to.
    40 g.eval('function f() {}');
    41 var fw = gw.makeDebuggeeValue(g.f);
    42 assertThrowsInstanceOf(function () { "use strict"; fw.script.staticLevel = 10; },
    43                        TypeError);

mercurial