michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: /* Create a prototype object with a setter property. */ michael@0: var protoSetterCount; michael@0: var proto = ({ set x(v) { protoSetterCount++; } }); michael@0: michael@0: /* Put a watchpoint on that setter. */ michael@0: var protoWatchCount; michael@0: proto.watch('x', function() { protoWatchCount++; }); michael@0: michael@0: /* Make an object with the above as its prototype. */ michael@0: function C() { } michael@0: C.prototype = proto; michael@0: var o = new C(); michael@0: michael@0: /* michael@0: * Set a watchpoint on the property in the inheriting object. We have michael@0: * defined this to mean "duplicate the property, setter and all, in the michael@0: * inheriting object." I don't think debugging observation mechanisms michael@0: * should mutate the program being run, but that's what we've got. michael@0: */ michael@0: var oWatchCount; michael@0: o.watch('x', function() { oWatchCount++; }); michael@0: michael@0: /* michael@0: * Assign to the property. This should trip the watchpoint on the inheriting object and michael@0: * the setter. michael@0: */ michael@0: protoSetterCount = protoWatchCount = oWatchCount = 0; michael@0: o.x = 1; michael@0: assertEq(protoWatchCount, 0); michael@0: assertEq(oWatchCount, 1); michael@0: assertEq(protoSetterCount, 1); michael@0: michael@0: reportCompare(true, true);