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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 350312;
8 var summary = 'Accessing wrong stack slot with nested catch/finally';
9 var actual = '';
10 var expect = '';
13 //-----------------------------------------------------------------------------
14 test();
15 //-----------------------------------------------------------------------------
17 function test()
18 {
19 enterFunc ('test');
20 printBugNumber(BUGNUMBER);
21 printStatus (summary);
23 var pfx = "(function (x) {try {if (x > 41) throw x}",
24 cg1a = " catch (e if e === 42) {var v = 'catch guard 1 ' + e; actual += v + ',';print(v);}"
25 cg1b = " catch (e if e === 42) {var v = 'catch guard 1 + throw ' + e; actual += v + ',';print(v); throw e;}"
26 cg2 = " catch (e if e === 43) {var v = 'catch guard 2 ' + e; actual += v + ',';print(v)}"
27 cat = " catch (e) {var v = 'catch all ' + e; print(v); if (e == 44) throw e}"
28 fin = " finally{var v = 'fin'; actual += v + ',';print(v)}",
29 end = "})";
31 var exphash = {
32 pfx: "(function (y) { var result = ''; y = y + ',';",
33 cg1a: " result += (y === '42,') ? ('catch guard 1 ' + y):'';",
34 cg1b: " result += (y === '42,') ? ('catch guard 1 + throw ' + y):'';",
35 cg2: " result += (y === '43,') ? ('catch guard 2 ' + y):'';",
36 cat: " result += (y > 41) ? ('catch all ' + y):'';",
37 fin: " result += 'fin,';",
38 end: "return result;})"
39 };
41 var src = [
42 pfx + fin + end,
43 pfx + cat + end,
44 pfx + cat + fin + end,
45 pfx + cg1a + end,
46 pfx + cg1a + fin + end,
47 pfx + cg1a + cat + end,
48 pfx + cg1a + cat + fin + end,
49 pfx + cg1a + cg2 + end,
50 pfx + cg1a + cg2 + fin + end,
51 pfx + cg1a + cg2 + cat + end,
52 pfx + cg1a + cg2 + cat + fin + end,
53 pfx + cg1b + end,
54 pfx + cg1b + fin + end,
55 pfx + cg1b + cat + end,
56 pfx + cg1b + cat + fin + end,
57 pfx + cg1b + cg2 + end,
58 pfx + cg1b + cg2 + fin + end,
59 pfx + cg1b + cg2 + cat + end,
60 pfx + cg1b + cg2 + cat + fin + end,
61 ];
63 var expsrc = [
64 exphash.pfx + exphash.fin + exphash.end,
65 exphash.pfx + exphash.cat + exphash.end,
66 exphash.pfx + exphash.cat + exphash.fin + exphash.end,
67 exphash.pfx + exphash.cg1a + exphash.end,
68 exphash.pfx + exphash.cg1a + exphash.fin + exphash.end,
69 exphash.pfx + exphash.cg1a + exphash.cat + exphash.end,
70 exphash.pfx + exphash.cg1a + exphash.cat + exphash.fin + exphash.end,
71 exphash.pfx + exphash.cg1a + exphash.cg2 + exphash.end,
72 exphash.pfx + exphash.cg1a + exphash.cg2 + exphash.fin + exphash.end,
73 exphash.pfx + exphash.cg1a + exphash.cg2 + exphash.cat + exphash.end,
74 exphash.pfx + exphash.cg1a + exphash.cg2 + exphash.cat + exphash.fin + exphash.end,
75 exphash.pfx + exphash.cg1b + exphash.end,
76 exphash.pfx + exphash.cg1b + exphash.fin + exphash.end,
77 exphash.pfx + exphash.cg1b + exphash.cat + exphash.end,
78 exphash.pfx + exphash.cg1b + exphash.cat + exphash.fin + exphash.end,
79 exphash.pfx + exphash.cg1b + exphash.cg2 + exphash.end,
80 exphash.pfx + exphash.cg1b + exphash.cg2 + exphash.fin + exphash.end,
81 exphash.pfx + exphash.cg1b + exphash.cg2 + exphash.cat + exphash.end,
82 exphash.pfx + exphash.cg1b + exphash.cg2 + exphash.cat + exphash.fin + exphash.end,
83 ];
85 for (var i in src) {
86 print("\n=== " + i + ": " + src[i]);
87 var f = eval(src[i]);
88 var exp = eval(expsrc[i]);
89 // dis(f);
90 print('decompiling: ' + f);
91 //print('decompiling exp: ' + exp);
93 actual = '';
94 try { expect = exp(41); f(41) } catch (e) { print('tried f(41), caught ' + e) }
95 reportCompare(expect, actual, summary);
97 actual = '';
98 try { expect = exp(42); f(42) } catch (e) { print('tried f(42), caught ' + e) }
99 reportCompare(expect, actual, summary);
101 actual = '';
102 try { expect = exp(43); f(43) } catch (e) { print('tried f(43), caught ' + e) }
103 reportCompare(expect, actual, summary);
105 actual = '';
106 try { expect = exp(44); f(44) } catch (e) { print('tried f(44), caught ' + e) }
107 reportCompare(expect, actual, summary);
109 actual = '';
110 try { expect = exp(45); f(45) } catch (e) { print('tried f(44), caught ' + e) }
111 reportCompare(expect, actual, summary);
113 }
115 exitFunc ('test');
116 }