js/src/jit-test/tests/basic/bug657227.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 var obj;
     2 var counter = 0;
     3 var p = Proxy.create({
     4     has : function(id) {
     5 	if (id == 'xyz') {
     6 	    ++counter;
     7 	    if (counter == 7) {
     8 		obj.__proto__ = null;
     9 	    }
    10 	    return true;
    11 	}
    12 	return false;
    13     },
    14     get : function(id) {
    15 	if (id == 'xyz')
    16 	    return 10;
    17     }
    18 });
    20 function test()
    21 {
    22     Object.prototype.__proto__ = null;
    23     obj = { xyz: 1};
    24     var n = 0;
    25     for (var i = 0; i != 100; ++i) {
    26 	var s = obj.xyz;
    27 	if (s)
    28 	    ++n;
    29 	if (i == 10) {
    30 	    delete obj.xyz;
    31 	    Object.prototype.__proto__ = p;
    32 	}
    34     }
    35 }
    37 try {
    38     test();
    39 } catch (e) {}

mercurial