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: 23 Nov 2002
9 * SUMMARY: Calling toString for an object derived from the Error class
10 * results in an TypeError (Rhino only)
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=181654
12 */
13 //-----------------------------------------------------------------------------
14 var UBound = 0;
15 var BUGNUMBER = '181654';
16 var summary = 'Calling toString for an object derived from the Error class should be possible.';
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 // derive MyError from Error
28 function MyError( msg )
29 {
30 this.message = msg;
31 }
32 MyError.prototype = new Error();
33 MyError.prototype.name = "MyError";
36 status = inSection(1);
37 var err1 = new MyError('msg1');
38 actual = examineThis(err1, 'msg1');
39 expect = EXPECTED_FORMAT;
40 addThis();
42 status = inSection(2);
43 var err2 = new MyError(String(err1));
44 actual = examineThis(err2, err1);
45 expect = EXPECTED_FORMAT;
46 addThis();
48 status = inSection(3);
49 var err3 = new MyError();
50 actual = examineThis(err3, EMPTY_STRING);
51 expect = EXPECTED_FORMAT;
52 addThis();
54 status = inSection(4);
55 var err4 = new MyError(EMPTY_STRING);
56 actual = examineThis(err4, EMPTY_STRING);
57 expect = EXPECTED_FORMAT;
58 addThis();
60 // now generate an error -
61 status = inSection(5);
62 try
63 {
64 throw new MyError("thrown");
65 }
66 catch(err5)
67 {
68 actual = examineThis(err5, "thrown");
69 }
70 expect = EXPECTED_FORMAT;
71 addThis();
75 //-----------------------------------------------------------------------------
76 test();
77 //-----------------------------------------------------------------------------
81 /*
82 * Searches err.toString() for err.name + ':' + err.message,
83 * with possible whitespace on each side of the colon sign.
84 *
85 * We allow for no colon in case err.message was not provided by the user.
86 * In such a case, SpiderMonkey and Rhino currently set err.message = '',
87 * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case.
88 *
89 * If this is ever changed to a non-empty string, e.g. 'undefined',
90 * you may have to modify |pattern| to take that into account -
91 *
92 */
93 function examineThis(err, msg)
94 {
95 var pattern = err.name + '\\s*:?\\s*' + msg;
96 return err.toString().search(RegExp(pattern));
97 }
100 function addThis()
101 {
102 statusitems[UBound] = status;
103 actualvalues[UBound] = actual;
104 expectedvalues[UBound] = expect;
105 UBound++;
106 }
109 function test()
110 {
111 enterFunc ('test');
112 printBugNumber(BUGNUMBER);
113 printStatus (summary);
115 for (var i = 0; i < UBound; i++)
116 {
117 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
118 }
120 exitFunc ('test');
121 }