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: 25 Nov 2002
9 * SUMMARY: Calling a user-defined superconstructor
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=181914, esp. Comment 10.
11 *
12 */
13 //-----------------------------------------------------------------------------
14 var UBound = 0;
15 var BUGNUMBER = '181914';
16 var summary = 'Calling a user-defined superconstructor';
17 var status = '';
18 var statusitems = [];
19 var actual = '';
20 var actualvalues = [];
21 var expect= '';
22 var expectedvalues = [];
23 var EMPTY_STRING = '';
24 var EXPECTED_FORMAT = 0;
27 // make a user-defined version of the Error constructor
28 function _Error(msg)
29 {
30 this.message = msg;
31 }
32 _Error.prototype = new Error();
33 _Error.prototype.name = '_Error';
36 // derive MyApplyError from _Error
37 function MyApplyError(msg)
38 {
39 if(this instanceof MyApplyError)
40 _Error.apply(this, arguments);
41 else
42 return new MyApplyError(msg);
43 }
44 MyApplyError.prototype = new _Error();
45 MyApplyError.prototype.name = "MyApplyError";
48 // derive MyCallError from _Error
49 function MyCallError(msg)
50 {
51 if(this instanceof MyCallError)
52 _Error.call(this, msg);
53 else
54 return new MyCallError(msg);
55 }
56 MyCallError.prototype = new _Error();
57 MyCallError.prototype.name = "MyCallError";
60 function otherScope(msg)
61 {
62 return MyApplyError(msg);
63 }
66 status = inSection(1);
67 var err1 = new MyApplyError('msg1');
68 actual = examineThis(err1, 'msg1');
69 expect = EXPECTED_FORMAT;
70 addThis();
72 status = inSection(2);
73 var err2 = new MyCallError('msg2');
74 actual = examineThis(err2, 'msg2');
75 expect = EXPECTED_FORMAT;
76 addThis();
78 status = inSection(3);
79 var err3 = MyApplyError('msg3');
80 actual = examineThis(err3, 'msg3');
81 expect = EXPECTED_FORMAT;
82 addThis();
84 status = inSection(4);
85 var err4 = MyCallError('msg4');
86 actual = examineThis(err4, 'msg4');
87 expect = EXPECTED_FORMAT;
88 addThis();
90 status = inSection(5);
91 var err5 = otherScope('msg5');
92 actual = examineThis(err5, 'msg5');
93 expect = EXPECTED_FORMAT;
94 addThis();
96 status = inSection(6);
97 var err6 = otherScope();
98 actual = examineThis(err6, EMPTY_STRING);
99 expect = EXPECTED_FORMAT;
100 addThis();
102 status = inSection(7);
103 var err7 = eval("MyApplyError('msg7')");
104 actual = examineThis(err7, 'msg7');
105 expect = EXPECTED_FORMAT;
106 addThis();
108 status = inSection(8);
109 var err8;
110 try
111 {
112 throw MyApplyError('msg8');
113 }
114 catch(e)
115 {
116 if(e instanceof Error)
117 err8 = e;
118 }
119 actual = examineThis(err8, 'msg8');
120 expect = EXPECTED_FORMAT;
121 addThis();
125 //-----------------------------------------------------------------------------
126 test();
127 //-----------------------------------------------------------------------------
131 // Searches |err.toString()| for |err.name + ':' + err.message|
132 function examineThis(err, msg)
133 {
134 var pattern = err.name + '\\s*:?\\s*' + msg;
135 return err.toString().search(RegExp(pattern));
136 }
139 function addThis()
140 {
141 statusitems[UBound] = status;
142 actualvalues[UBound] = actual;
143 expectedvalues[UBound] = expect;
144 UBound++;
145 }
148 function test()
149 {
150 enterFunc ('test');
151 printBugNumber(BUGNUMBER);
152 printStatus (summary);
154 for (var i = 0; i < UBound; i++)
155 {
156 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
157 }
159 exitFunc ('test');
160 }