tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Environment-setVariable-12.js (776B)


      1 // setVariable can create a new property on a with block's bindings object, if
      2 // it is shadowing an existing property on the prototype chain.
      3 
      4 var g = newGlobal({newCompartment: true});
      5 var dbg = Debugger(g);
      6 dbg.onDebuggerStatement = function (frame) {
      7    var env = frame.environment.find("x");
      8    env.setVariable("x", 2);
      9 };
     10 g.eval("var obj1 = {x: 1}, obj2 = Object.create(obj1), z; with (obj2) { debugger; z = x; }");
     11 assertEq(g.obj1.x, 1);
     12 assertEq(g.obj2.x, 2);
     13 assertEq(g.z, 2);
     14 
     15 // The property created by setVariable is like the one created by ordinary
     16 // assignment in a with-block.
     17 var desc = Object.getOwnPropertyDescriptor(g.obj2, "x");
     18 assertEq(desc.configurable, true);
     19 assertEq(desc.enumerable, true);
     20 assertEq(desc.writable, true);
     21 assertEq(desc.value, 2);