js/src/jit-test/tests/debug/Frame-evalWithBindings-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 // evalWithBindings basics
     3 var g = newGlobal();
     4 var dbg = new Debugger(g);
     5 var hits = 0;
     6 dbg.onDebuggerStatement = function (frame) {
     7     assertEq(frame.evalWithBindings("x", {x: 2}).return, 2);
     8     assertEq(frame.evalWithBindings("x + y", {x: 2}).return, 5);
     9     hits++;
    10 };
    12 // in global code
    13 g.y = 3;
    14 g.eval("debugger;");
    16 // in function code
    17 g.y = "fail";
    18 g.eval("function f(y) { debugger; }");
    19 g.f(3);
    21 // in direct eval code
    22 g.eval("function f() { var y = 3; eval('debugger;'); }");
    23 g.f();
    25 // in strict eval code with var
    26 g.eval("function f() { 'use strict'; eval('var y = 3; debugger;'); }");
    27 g.f();
    29 // in a with block
    30 g.eval("with ({y: 3}) { debugger; }");
    32 // shadowing
    33 g.eval("let (x = 50, y = 3) { debugger; }");
    35 assertEq(hits, 6);

mercurial