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 *
8 * Date: 05 June 2003
9 * SUMMARY: Testing |with (f)| inside the definition of |function f()|
10 *
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=208496
12 *
13 */
14 //-----------------------------------------------------------------------------
15 var UBound = 0;
16 var BUGNUMBER = 208496;
17 var summary = 'Testing |with (f)| inside the definition of |function f()|';
18 var status = '';
19 var statusitems = [];
20 var actual = '(TEST FAILURE)';
21 var actualvalues = [];
22 var expect= '';
23 var expectedvalues = [];
26 /*
27 * GLOBAL SCOPE
28 */
29 function f(par)
30 {
31 var a = par;
33 with(f)
34 {
35 var b = par;
36 actual = b;
37 }
38 }
40 status = inSection(1);
41 f('abc'); // this sets |actual|
42 expect = 'abc';
43 addThis();
45 status = inSection(2);
46 f(111 + 222); // sets |actual|
47 expect = 333;
48 addThis();
51 /*
52 * EVAL SCOPE
53 */
54 var s = '';
55 s += 'function F(par)';
56 s += '{';
57 s += ' var a = par;';
59 s += ' with(F)';
60 s += ' {';
61 s += ' var b = par;';
62 s += ' actual = b;';
63 s += ' }';
64 s += '}';
66 s += 'status = inSection(3);';
67 s += 'F("abc");'; // sets |actual|
68 s += 'expect = "abc";';
69 s += 'addThis();';
71 s += 'status = inSection(4);';
72 s += 'F(111 + 222);'; // sets |actual|
73 s += 'expect = 333;';
74 s += 'addThis();';
75 eval(s);
78 /*
79 * FUNCTION SCOPE
80 */
81 function g(par)
82 {
83 // Add outer variables to complicate the scope chain -
84 var a = '(TEST FAILURE)';
85 var b = '(TEST FAILURE)';
86 h(par);
88 function h(par)
89 {
90 var a = par;
92 with(h)
93 {
94 var b = par;
95 actual = b;
96 }
97 }
98 }
100 status = inSection(5);
101 g('abc'); // sets |actual|
102 expect = 'abc';
103 addThis();
105 status = inSection(6);
106 g(111 + 222); // sets |actual|
107 expect = 333;
108 addThis();
113 //-----------------------------------------------------------------------------
114 test();
115 //-----------------------------------------------------------------------------
119 function addThis()
120 {
121 statusitems[UBound] = status;
122 actualvalues[UBound] = actual;
123 expectedvalues[UBound] = expect;
124 UBound++;
125 }
128 function test()
129 {
130 enterFunc('test');
131 printBugNumber(BUGNUMBER);
132 printStatus(summary);
134 for (var i=0; i<UBound; i++)
135 {
136 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
137 }
139 exitFunc ('test');
140 }