Sat, 03 Jan 2015 20:18:00 +0100
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 | var key = {}; |
michael@0 | 2 | var wm = WeakMap(); |
michael@0 | 3 | |
michael@0 | 4 | assertEq(wm.has(key), false); |
michael@0 | 5 | // Clearing an already empty WeakMap |
michael@0 | 6 | wm.clear(); |
michael@0 | 7 | assertEq(wm.has(key), false); |
michael@0 | 8 | |
michael@0 | 9 | // Clearing a WeakMap with a live key |
michael@0 | 10 | wm.set(key, 42); |
michael@0 | 11 | assertEq(wm.has(key), true); |
michael@0 | 12 | wm.clear(); |
michael@0 | 13 | assertEq(wm.has(key), false); |
michael@0 | 14 | |
michael@0 | 15 | // Clearing a WeakMap with keys turned to garbage |
michael@0 | 16 | wm.set(key, {}); |
michael@0 | 17 | for (var i = 0; i < 10; i++) |
michael@0 | 18 | wm.set({}, {}); |
michael@0 | 19 | assertEq(wm.has(key), true); |
michael@0 | 20 | wm.clear(); |
michael@0 | 21 | assertEq(wm.has(key), false); |
michael@0 | 22 | |
michael@0 | 23 | // Clearing a WeakMap with keys turned to garbage and after doing a GC |
michael@0 | 24 | wm.set(key, {}); |
michael@0 | 25 | for (var i = 0; i < 10; i++) |
michael@0 | 26 | wm.set({}, {}); |
michael@0 | 27 | assertEq(wm.has(key), true); |
michael@0 | 28 | gc(); |
michael@0 | 29 | assertEq(wm.has(key), true); |
michael@0 | 30 | wm.clear(); |
michael@0 | 31 | assertEq(wm.has(key), false); |
michael@0 | 32 | |
michael@0 | 33 | // More testing when the key is no longer live |
michael@0 | 34 | wm.set(key, {}); |
michael@0 | 35 | key = null; |
michael@0 | 36 | wm.clear(); |
michael@0 | 37 | gc(); |
michael@0 | 38 | var key2 = {}; |
michael@0 | 39 | wm.set(key2, {}); |
michael@0 | 40 | key2 = null; |
michael@0 | 41 | gc(); |
michael@0 | 42 | wm.clear(); |