2
* Any copyright is dedicated to the Public Domain.
3
* http://creativecommons.org/licenses/publicdomain/
6
/* A stock watcher function. */
8
function watcher(id, oldval, newval) { watcherCount++; return newval; }
10
/* Create an object with a JavaScript setter. */
12
var o = { w:2, set x(v) { setterCount++; } };
15
* Put the object in dictionary mode, so that JSObject::putProperty will
16
* mutate its shapes instead of creating new ones.
21
* Place a watchpoint on the property. The watchpoint structure holds the
22
* original JavaScript setter, and a pointer to the shape.
24
o.watch('x', watcher);
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).
31
Object.defineProperty(o, 'x', { value:3,
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.
41
watcherCount = setterCount = 0;
43
assertEq(watcherCount, 1);
44
assertEq(setterCount, 0);
46
reportCompare(true, true);