js/src/jit-test/tests/debug/Environment-setVariable-08.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Environment-setVariable-08.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,29 @@
     1.4 +// setVariable throws if no binding exists.
     1.5 +
     1.6 +load(libdir + "asserts.js");
     1.7 +
     1.8 +function test(code) {
     1.9 +    var g = newGlobal();
    1.10 +    var dbg = new Debugger(g);
    1.11 +    var hits = 0;
    1.12 +    dbg.onDebuggerStatement = function (frame) {
    1.13 +        var env = frame.older.environment;
    1.14 +        assertThrowsInstanceOf(function () { env.setVariable("y", 2); }, Error);
    1.15 +        hits++;
    1.16 +    };
    1.17 +    g.eval("var y = 0; function d() { debugger; }");
    1.18 +
    1.19 +    assertEq(g.eval(code), 0);
    1.20 +
    1.21 +    assertEq(g.y, 0);
    1.22 +    assertEq(hits, 1);
    1.23 +}
    1.24 +
    1.25 +// local scope of non-heavyweight function
    1.26 +test("function f() { var x = 1; d(); return y; }  f();");
    1.27 +
    1.28 +// block scope
    1.29 +test("function h(x) { if (x) { let x = 1; d(); return y; } }  h(3);");
    1.30 +
    1.31 +// strict eval scope
    1.32 +test("'use strict'; eval('d(); y;');");

mercurial