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 // getLineOffsets works with extended instructions, such as JSOP_GOTOX.
3 var g = newGlobal();
4 g.line0 = null;
5 var dbg = Debugger(g);
6 var where;
7 dbg.onDebuggerStatement = function (frame) {
8 var s = frame.script;
9 var offs;
10 var lineno = g.line0 + where;
11 offs = s.getLineOffsets(lineno);
12 for (var i = 0; i < offs.length; i++) {
13 assertEq(s.getOffsetLine(offs[i]), lineno);
14 s.setBreakpoint(offs[i], {hit: function (frame) { g.log += 'B'; }});
15 }
16 g.log += 'A';
17 };
19 function test(s) {
20 assertEq(s.charAt(s.length - 1) !== '\n', true);
21 var count = s.split(/\n/).length; // number of lines in s
22 g.i = 0;
23 g.log = '';
24 where = 1 + count;
25 g.eval("line0 = Error().lineNumber;\n" +
26 "debugger;\n" + // line0 + 1
27 s + // line0 + 2 ... line0 + where
28 " log += 'C';\n");
29 assertEq(g.log, 'ABC');
30 }
32 function repeat(s) {
33 return Array((1 << 14) + 1).join(s); // 16K copies of s
34 }
35 var long_expr = "i" + repeat(" + i");
36 var long_throw_stmt = "throw " + long_expr + ";\n";
38 // long break (JSOP_GOTOX)
39 test("for (;;) {\n" +
40 " if (i === 0)\n" +
41 " break;\n" +
42 " " + long_throw_stmt +
43 "}");
45 // long continue (JSOP_GOTOX)
46 test("do {\n" +
47 " if (i === 0)\n" +
48 " continue;\n" +
49 " " + long_throw_stmt +
50 "} while (i !== 0);");
52 // long if consequent (JSOP_IFEQX)
53 test("if (i === 2) {\n" +
54 " " + long_throw_stmt +
55 "}");
57 // long catch-block with finally (JSOP_GOSUBX)
58 test("try {\n" +
59 " i = 0;\n" +
60 "} catch (exc) {\n" +
61 " throw " + long_expr + ";\n" +
62 "} finally {\n" +
63 " i = 1;\n" +
64 "}");
66 // long case (JSOP_TABLESWITCHX)
67 test("switch (i) {\n" +
68 " default:\n" +
69 " case 1: " + long_throw_stmt +
70 " case 0: i++; }");
72 test("switch (i) {\n" +
73 " case 1: case 2: case 3: " + long_throw_stmt +
74 " default: i++; }");
76 // long case (JSOP_LOOKUPSWITCHX)
77 test("switch ('' + i) {\n" +
78 " default:\n" +
79 " case '1': " + long_throw_stmt +
80 " case '0': i++; }");
82 test("switch (i) {\n" +
83 " case '1': case '2': case '3': " + long_throw_stmt +
84 " default: i++; }");
86 // long case or case-expression (JSOP_CASEX)
87 test("switch (i) {\n" +
88 " case i + 1 - i:\n" +
89 " default:\n" +
90 " " + long_throw_stmt +
91 " case i + i:\n" +
92 " i++; break; }");
94 // long case when JSOP_CASE is used (JSOP_DEFAULTX)
95 test("switch (i) {\n" +
96 " case i + 1 - i:\n" +
97 " " + long_throw_stmt +
98 " default:\n" +
99 " i++; break; }");