Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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, oldval, newval) { watcherCount++; return newval; }
10 /* Create an object with a JavaScript setter. */
11 var setterCount;
12 var o = { w:2, set x(v) { setterCount++; } };
14 /*
15 * Put the object in dictionary mode, so that JSObject::putProperty will
16 * mutate its shapes instead of creating new ones.
17 */
18 delete o.w;
20 /*
21 * Place a watchpoint on the property. The watchpoint structure holds the
22 * original JavaScript setter, and a pointer to the shape.
23 */
24 o.watch('x', watcher);
26 /*
27 * Replace the accessor property with a value property. The shape's setter
28 * should become a non-JS setter, js_watch_set, and the watchpoint
29 * structure's saved setter should be updated (in this case, cleared).
30 */
31 Object.defineProperty(o, 'x', { value:3,
32 writable:true,
33 enumerable:true,
34 configurable:true });
36 /*
37 * Assign to the property. This should trigger js_watch_set, which should
38 * call the handler, and then see that there is no JS-level setter to pass
39 * control on to, and return.
40 */
41 watcherCount = setterCount = 0;
42 o.x = 3;
43 assertEq(watcherCount, 1);
44 assertEq(setterCount, 0);
46 reportCompare(true, true);