|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/licenses/publicdomain/ |
|
4 */ |
|
5 |
|
6 /* Create a prototype object with a setter property. */ |
|
7 var protoSetterCount; |
|
8 var proto = ({ set x(v) { protoSetterCount++; } }); |
|
9 |
|
10 /* Put a watchpoint on that setter. */ |
|
11 var protoWatchCount; |
|
12 proto.watch('x', function() { protoWatchCount++; }); |
|
13 |
|
14 /* Make an object with the above as its prototype. */ |
|
15 function C() { } |
|
16 C.prototype = proto; |
|
17 var o = new C(); |
|
18 |
|
19 /* |
|
20 * Set a watchpoint on the property in the inheriting object. We have |
|
21 * defined this to mean "duplicate the property, setter and all, in the |
|
22 * inheriting object." I don't think debugging observation mechanisms |
|
23 * should mutate the program being run, but that's what we've got. |
|
24 */ |
|
25 var oWatchCount; |
|
26 o.watch('x', function() { oWatchCount++; }); |
|
27 |
|
28 /* |
|
29 * Assign to the property. This should trip the watchpoint on the inheriting object and |
|
30 * the setter. |
|
31 */ |
|
32 protoSetterCount = protoWatchCount = oWatchCount = 0; |
|
33 o.x = 1; |
|
34 assertEq(protoWatchCount, 0); |
|
35 assertEq(oWatchCount, 1); |
|
36 assertEq(protoSetterCount, 1); |
|
37 |
|
38 reportCompare(true, true); |