js/src/tests/ecma_5/extensions/watch-value-prop-becoming-setter.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  */
     6 /* A stock watcher function. */
     7 var watcherCount;
     8 function watcher(id, old, newval) {
     9     watcherCount++;
    10     return newval; 
    11 }
    13 /* Create an object with a value property. */
    14 var o = { w:2, x:3 };
    16 /*
    17  * Place a watchpoint on the value property. The watchpoint structure holds
    18  * the original JavaScript setter, and a pointer to the shape.
    19  */
    20 o.watch('x', watcher);
    22 /*
    23  * Put the object in dictionary mode, so that JSObject::putProperty will 
    24  * mutate its shapes instead of creating new ones.
    25  */
    26 delete o.w;
    28 /*
    29  * Replace the value property with a setter.
    30  */
    31 var setterCount;
    32 o.__defineSetter__('x', function() { setterCount++; });
    34 /*
    35  * Trigger the watchpoint. The watchpoint handler should run, and then the
    36  * setter should run.
    37  */
    38 watcherCount = setterCount = 0;
    39 o.x = 4;
    40 assertEq(watcherCount, 1);
    41 assertEq(setterCount, 1);
    43 reportCompare(true, true);

mercurial