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

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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.
     4 var g = newGlobal();
     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);
    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);

mercurial