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: 31 January 2003
9 * SUMMARY: Testing regular expressions of form /(x|y){n,}/
10 *
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=191479
12 *
13 */
14 //-----------------------------------------------------------------------------
15 var i = 0;
16 var BUGNUMBER = 191479;
17 var summary = 'Testing regular expressions of form /(x|y){n,}/';
18 var status = '';
19 var statusmessages = new Array();
20 var pattern = '';
21 var patterns = new Array();
22 var string = '';
23 var strings = new Array();
24 var actualmatch = '';
25 var actualmatches = new Array();
26 var expectedmatch = '';
27 var expectedmatches = new Array();
30 status = inSection(1);
31 string = '12 3 45';
32 pattern = /(\d|\d\s){2,}/;
33 actualmatch = string.match(pattern);
34 expectedmatch = Array('12', '2');
35 addThis();
37 status = inSection(2);
38 string = '12 3 45';
39 pattern = /(\d|\d\s){4,}/;
40 actualmatch = string.match(pattern);
41 expectedmatch = Array(string, '5');
42 addThis();
44 status = inSection(3);
45 string = '12 3 45';
46 pattern = /(\d|\d\s)+/;
47 actualmatch = string.match(pattern);
48 expectedmatch = Array('12', '2');
49 addThis();
51 status = inSection(4);
52 string = '12 3 45';
53 pattern = /(\d\s?){4,}/;
54 actualmatch = string.match(pattern);
55 expectedmatch = Array(string, '5');
56 addThis();
58 /*
59 * Let's reverse the operands in Sections 1-3 above -
60 */
61 status = inSection(5);
62 string = '12 3 45';
63 pattern = /(\d\s|\d){2,}/;
64 actualmatch = string.match(pattern);
65 expectedmatch = Array(string, '5');
66 addThis();
68 status = inSection(6);
69 string = '12 3 45';
70 pattern = /(\d\s|\d){4,}/;
71 actualmatch = string.match(pattern);
72 expectedmatch = Array(string, '5');
73 addThis();
75 status = inSection(7);
76 string = '12 3 45';
77 pattern = /(\d\s|\d)+/;
78 actualmatch = string.match(pattern);
79 expectedmatch = Array(string, '5');
80 addThis();
83 /*
84 * Let's take all 7 sections above and make each quantifer non-greedy.
85 *
86 * This is done by appending ? to it. It doesn't change the meaning of
87 * the quantifier, but makes it non-greedy, which affects the results -
88 */
89 status = inSection(8);
90 string = '12 3 45';
91 pattern = /(\d|\d\s){2,}?/;
92 actualmatch = string.match(pattern);
93 expectedmatch = Array('12', '2');
94 addThis();
96 status = inSection(9);
97 string = '12 3 45';
98 pattern = /(\d|\d\s){4,}?/;
99 actualmatch = string.match(pattern);
100 expectedmatch = Array('12 3 4', '4');
101 addThis();
103 status = inSection(10);
104 string = '12 3 45';
105 pattern = /(\d|\d\s)+?/;
106 actualmatch = string.match(pattern);
107 expectedmatch = Array('1', '1');
108 addThis();
110 status = inSection(11);
111 string = '12 3 45';
112 pattern = /(\d\s?){4,}?/;
113 actualmatch = string.match(pattern);
114 expectedmatch = Array('12 3 4', '4');
115 addThis();
117 status = inSection(12);
118 string = '12 3 45';
119 pattern = /(\d\s|\d){2,}?/;
120 actualmatch = string.match(pattern);
121 expectedmatch = Array('12 ', '2 ');
122 addThis();
124 status = inSection(13);
125 string = '12 3 45';
126 pattern = /(\d\s|\d){4,}?/;
127 actualmatch = string.match(pattern);
128 expectedmatch = Array('12 3 4', '4');
129 addThis();
131 status = inSection(14);
132 string = '12 3 45';
133 pattern = /(\d\s|\d)+?/;
134 actualmatch = string.match(pattern);
135 expectedmatch = Array('1', '1');
136 addThis();
140 //-----------------------------------------------------------------------------
141 test();
142 //-----------------------------------------------------------------------------
146 function addThis()
147 {
148 statusmessages[i] = status;
149 patterns[i] = pattern;
150 strings[i] = string;
151 actualmatches[i] = actualmatch;
152 expectedmatches[i] = expectedmatch;
153 i++;
154 }
157 function test()
158 {
159 enterFunc ('test');
160 printBugNumber(BUGNUMBER);
161 printStatus (summary);
162 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
163 exitFunc ('test');
164 }