js/src/tests/js1_8_5/extensions/regress-604781-1.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 // Any copyright is dedicated to the Public Domain.
     2 // http://creativecommons.org/licenses/publicdomain/
     4 var watcherCount, setterCount;
     5 function watcher(id, oldval, newval) { watcherCount++; return newval; }
     6 function setter(newval) { setterCount++; }
     8 var p = { set x(v) { setter(v); } };
     9 p.watch('x', watcher);
    11 watcherCount = setterCount = 0;
    12 p.x = 2;
    13 assertEq(setterCount, 1);
    14 assertEq(watcherCount, 1);
    16 var o = Object.defineProperty({}, 'x', { set:setter, enumerable:true, configurable:true });
    17 o.watch('x', watcher);
    19 watcherCount = setterCount = 0;
    20 o.x = 2;
    21 assertEq(setterCount, 1);
    22 assertEq(watcherCount, 1);
    24 reportCompare(0, 0, 'ok');

mercurial