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.
1 // Storing a Debugger.Object as a key in a WeakMap protects it from GC as long as
2 // the referent is alive.
4 var g = newGlobal();
5 var N = g.N = 10;
6 var dbg = Debugger(g);
7 var cache = new WeakMap;
9 var i = 0;
10 dbg.onDebuggerStatement = function (frame) {
11 cache.set(frame.arguments[0], i++);
12 };
13 g.eval("function f(x) { debugger; }");
14 g.eval("var arr = [], j; for (j = 0; j < N; j++) arr[j] = {};");
15 g.eval("for (j = 0; j < N; j++) f(arr[j]);");
16 assertEq(i, N);
18 gc(); gc();
20 i = 0;
21 dbg.onDebuggerStatement = function (frame) {
22 assertEq(cache.get(frame.arguments[0]), i++)
23 };
24 g.eval("for (j = 0; j < N; j++) f(arr[j]);");
25 assertEq(i, N);