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 // Debugger.Script.prototype.staticLevel returns the script's static level.
2 load(libdir + 'asserts.js');
4 var g = newGlobal();
5 var dbg = Debugger();
6 var gw = dbg.addDebuggee(g);
8 function test(expr, level) {
9 var log;
10 dbg.onDebuggerStatement = function (frame) {
11 log += 'd';
12 assertEq(frame.script.staticLevel, level);
13 };
15 print("Testing: " + expr);
17 log = '';
18 // The shell's 'evaluate' runs its argument as global code.
19 g.evaluate(expr);
20 assertEq(log, 'd');
21 }
24 test("debugger;", 0);
25 test("(function () { debugger; })()", 1);
26 test("(function () { (function () { debugger; })(); })()", 2);
27 test("(function () { (function () { (function () { debugger; })(); })(); })()", 3);
29 test("eval('debugger;');", 1);
30 test("eval('eval(\\\'debugger;\\\');');", 2);
31 test("evil = eval; eval('evil(\\\'debugger;\\\');');", 0); // I don't think it's evil at all!
32 test("(function () { eval('debugger;'); })();", 2);
33 test("evil = eval; (function () { evil('debugger;'); })();", 0);
35 // Generators' expressions are within a synthesized function's body.
36 test("((function () { debugger; })() for (x in [1])).next();", 2);
37 test("(x for (x in ((function () { debugger; })(), [1]))).next();", 2);
39 // The staticLevel accessor can't be assigned to.
40 g.eval('function f() {}');
41 var fw = gw.makeDebuggeeValue(g.f);
42 assertThrowsInstanceOf(function () { "use strict"; fw.script.staticLevel = 10; },
43 TypeError);