js/src/tests/ecma_5/extensions/watch-replaced-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.

michael@0 1 /*
michael@0 2 * Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/licenses/publicdomain/
michael@0 4 */
michael@0 5
michael@0 6 /* A stock watcher function. */
michael@0 7 var watcherCount;
michael@0 8 function watcher(id, oldval, newval) { watcherCount++; return newval; }
michael@0 9
michael@0 10 /* Create an object with a JavaScript setter. */
michael@0 11 var setterCount;
michael@0 12 var o = { w:2, set x(v) { setterCount++; } };
michael@0 13
michael@0 14 /*
michael@0 15 * Put the object in dictionary mode, so that JSObject::putProperty will
michael@0 16 * mutate its shapes instead of creating new ones.
michael@0 17 */
michael@0 18 delete o.w;
michael@0 19
michael@0 20 /*
michael@0 21 * Place a watchpoint on the property. The watchpoint structure holds the
michael@0 22 * original JavaScript setter, and a pointer to the shape.
michael@0 23 */
michael@0 24 o.watch('x', watcher);
michael@0 25
michael@0 26 /*
michael@0 27 * Replace the accessor property with a value property. The shape's setter
michael@0 28 * should become a non-JS setter, js_watch_set, and the watchpoint
michael@0 29 * structure's saved setter should be updated (in this case, cleared).
michael@0 30 */
michael@0 31 Object.defineProperty(o, 'x', { value:3,
michael@0 32 writable:true,
michael@0 33 enumerable:true,
michael@0 34 configurable:true });
michael@0 35
michael@0 36 /*
michael@0 37 * Assign to the property. This should trigger js_watch_set, which should
michael@0 38 * call the handler, and then see that there is no JS-level setter to pass
michael@0 39 * control on to, and return.
michael@0 40 */
michael@0 41 watcherCount = setterCount = 0;
michael@0 42 o.x = 3;
michael@0 43 assertEq(watcherCount, 1);
michael@0 44 assertEq(setterCount, 0);
michael@0 45
michael@0 46 reportCompare(true, true);

mercurial