js/src/tests/ecma_5/extensions/watchpoint-deletes-JSPropertyOp-setter.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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 function make_watcher(name) {
michael@0 7 return function (id, oldv, newv) {
michael@0 8 print("watched " + name + "[0]");
michael@0 9 };
michael@0 10 }
michael@0 11
michael@0 12 var o, p;
michael@0 13 function f(flag) {
michael@0 14 if (flag) {
michael@0 15 o = arguments;
michael@0 16 } else {
michael@0 17 p = arguments;
michael@0 18 o.watch(0, make_watcher('o'));
michael@0 19 p.watch(0, make_watcher('p'));
michael@0 20
michael@0 21 /*
michael@0 22 * Previously, the watchpoint implementation actually substituted its magic setter
michael@0 23 * functions for the setters of shared shapes, and then 1) carefully ignored calls
michael@0 24 * to its magic setter from unrelated objects, and 2) avoided restoring the
michael@0 25 * original setter until all watchpoints on that shape had been removed.
michael@0 26 *
michael@0 27 * However, when the watchpoint code began using JSObject::changeProperty and
michael@0 28 * js_ChangeNativePropertyAttrs to change shapes' setters, the shape tree code
michael@0 29 * became conscious of the presence of watchpoints, and shared shapes between
michael@0 30 * objects only when their watchpoint nature coincided. Clearing the magic setter
michael@0 31 * from one object's shape would not affect other objects, because the
michael@0 32 * watchpointed and non-watchpointed shapes were distinct if they were shared.
michael@0 33 *
michael@0 34 * Thus, the first unwatch call must go ahead and fix p's shape, even though a
michael@0 35 * watchpoint exists on the same shape in o. o's watchpoint's presence shouldn't
michael@0 36 * cause 'unwatch' to leave p's magic setter in place.
michael@0 37 */
michael@0 38
michael@0 39 /* DropWatchPointAndUnlock would see o's watchpoint, and not change p's property. */
michael@0 40 p.unwatch(0);
michael@0 41
michael@0 42 /* DropWatchPointAndUnlock would fix o's property, but not p's; p's setter would be gone. */
michael@0 43 o.unwatch(0);
michael@0 44
michael@0 45 /* This would fail to invoke the arguments object's setter. */
michael@0 46 p[0] = 4;
michael@0 47
michael@0 48 /* And the formal parameter would not get updated. */
michael@0 49 assertEq(flag, 4);
michael@0 50 }
michael@0 51 }
michael@0 52
michael@0 53 f(true);
michael@0 54 f(false);
michael@0 55
michael@0 56 reportCompare(true, true);

mercurial