js/src/jit-test/tests/debug/Environment-setVariable-12.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-12.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,21 @@
     1.4 +// setVariable can create a new property on a with block's bindings object, if
     1.5 +// it is shadowing an existing property on the prototype chain.
     1.6 +
     1.7 +var g = newGlobal();
     1.8 +var dbg = Debugger(g);
     1.9 +dbg.onDebuggerStatement = function (frame) {
    1.10 +    var env = frame.environment.find("x");
    1.11 +    env.setVariable("x", 2);
    1.12 +};
    1.13 +g.eval("var obj1 = {x: 1}, obj2 = Object.create(obj1), z; with (obj2) { debugger; z = x; }");
    1.14 +assertEq(g.obj1.x, 1);
    1.15 +assertEq(g.obj2.x, 2);
    1.16 +assertEq(g.z, 2);
    1.17 +
    1.18 +// The property created by setVariable is like the one created by ordinary
    1.19 +// assignment in a with-block.
    1.20 +var desc = Object.getOwnPropertyDescriptor(g.obj2, "x");
    1.21 +assertEq(desc.configurable, true);
    1.22 +assertEq(desc.enumerable, true);
    1.23 +assertEq(desc.writable, true);
    1.24 +assertEq(desc.value, 2);

mercurial