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