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 * Date: 26 November 2000
8 *
9 *
10 * SUMMARY: This test arose from Bugzilla bug 57631:
11 * "RegExp with invalid pattern or invalid flag causes segfault"
12 *
13 * Either error should throw an exception of type SyntaxError,
14 * and we check to see that it does...
15 */
16 //-----------------------------------------------------------------------------
17 var BUGNUMBER = '57631';
18 var summary = 'Testing new RegExp(pattern,flag) with illegal pattern or flag';
19 var statprefix = 'Testing for error creating illegal RegExp object on pattern ';
20 var statsuffix = 'and flag ';
21 var cnSUCCESS = 'SyntaxError';
22 var cnFAILURE = 'not a SyntaxError';
23 var singlequote = "'";
24 var i = -1; var j = -1; var s = ''; var f = '';
25 var obj = {};
26 var status = ''; var actual = ''; var expect = ''; var msg = '';
27 var legalpatterns = new Array(); var illegalpatterns = new Array();
28 var legalflags = new Array(); var illegalflags = new Array();
31 // valid regular expressions to try -
32 legalpatterns[0] = '';
33 legalpatterns[1] = 'abc';
34 legalpatterns[2] = '(.*)(3-1)\s\w';
35 legalpatterns[3] = '(.*)(...)\\s\\w';
36 legalpatterns[4] = '[^A-Za-z0-9_]';
37 legalpatterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)';
39 // invalid regular expressions to try -
40 illegalpatterns[0] = '(?)';
41 illegalpatterns[1] = '(a';
42 illegalpatterns[2] = '( ]';
43 //illegalpatterns[3] = '\d{1,s}';
45 // valid flags to try -
46 legalflags[0] = 'i';
47 legalflags[1] = 'g';
48 legalflags[2] = 'm';
49 legalflags[3] = undefined;
51 // invalid flags to try -
52 illegalflags[0] = 'a';
53 illegalflags[1] = 123;
54 illegalflags[2] = new RegExp();
58 //-------------------------------------------------------------------------------------------------
59 test();
60 //-------------------------------------------------------------------------------------------------
63 function test()
64 {
65 enterFunc ('test');
66 printBugNumber(BUGNUMBER);
67 printStatus (summary);
69 testIllegalRegExps(legalpatterns, illegalflags);
70 testIllegalRegExps(illegalpatterns, legalflags);
71 testIllegalRegExps(illegalpatterns, illegalflags);
73 exitFunc ('test');
74 }
77 // This function will only be called where all the patterns are illegal, or all the flags
78 function testIllegalRegExps(patterns, flags)
79 {
80 for (i in patterns)
81 {
82 s = patterns[i];
84 for (j in flags)
85 {
86 f = flags[j];
87 status = getStatus(s, f);
88 actual = cnFAILURE;
89 expect = cnSUCCESS;
91 try
92 {
93 // This should cause an exception if either s or f is illegal -
94 eval('obj = new RegExp(s, f);');
95 }
96 catch(e)
97 {
98 // We expect to get a SyntaxError - test for this:
99 if (e instanceof SyntaxError)
100 actual = cnSUCCESS;
101 }
103 reportCompare(expect, actual, status);
104 }
105 }
106 }
109 function getStatus(regexp, flag)
110 {
111 return (statprefix + quote(regexp) + statsuffix + quote(flag));
112 }
115 function quote(text)
116 {
117 return (singlequote + text + singlequote);
118 }