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: 28 December 2000
8 *
9 * SUMMARY: Testing regular expressions containing the ? character.
10 * Arose from Bugzilla bug 57572: "RegExp with ? matches incorrectly"
11 *
12 * See http://bugzilla.mozilla.org/show_bug.cgi?id=57572
13 *
14 */
15 //-----------------------------------------------------------------------------
16 var i = 0;
17 var BUGNUMBER = 57572;
18 var summary = 'Testing regular expressions containing "?"';
19 var cnEmptyString = ''; var cnSingleSpace = ' ';
20 var status = '';
21 var statusmessages = new Array();
22 var pattern = '';
23 var patterns = new Array();
24 var string = '';
25 var strings = new Array();
26 var actualmatch = '';
27 var actualmatches = new Array();
28 var expectedmatch = '';
29 var expectedmatches = new Array();
32 status = inSection(1);
33 pattern = /(\S+)?(.*)/;
34 string = 'Test this';
35 actualmatch = string.match(pattern);
36 expectedmatch = Array(string, 'Test', ' this'); //single space in front of 'this'
37 addThis();
39 status = inSection(2);
40 pattern = /(\S+)? ?(.*)/; //single space between the ? characters
41 string= 'Test this';
42 actualmatch = string.match(pattern);
43 expectedmatch = Array(string, 'Test', 'this'); //NO space in front of 'this'
44 addThis();
46 status = inSection(3);
47 pattern = /(\S+)?(.*)/;
48 string = 'Stupid phrase, with six - (short) words';
49 actualmatch = string.match(pattern);
50 expectedmatch = Array(string, 'Stupid', ' phrase, with six - (short) words'); //single space in front of 'phrase'
51 addThis();
53 status = inSection(4);
54 pattern = /(\S+)? ?(.*)/; //single space between the ? characters
55 string = 'Stupid phrase, with six - (short) words';
56 actualmatch = string.match(pattern);
57 expectedmatch = Array(string, 'Stupid', 'phrase, with six - (short) words'); //NO space in front of 'phrase'
58 addThis();
61 // let's add an extra back-reference this time - three instead of two -
62 status = inSection(5);
63 pattern = /(\S+)?( ?)(.*)/; //single space before second ? character
64 string = 'Stupid phrase, with six - (short) words';
65 actualmatch = string.match(pattern);
66 expectedmatch = Array(string, 'Stupid', cnSingleSpace, 'phrase, with six - (short) words');
67 addThis();
69 status = inSection(6);
70 pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character
71 string = 'AAABBB';
72 actualmatch = string.match(pattern);
73 expectedmatch = Array(string, 'AAABB', cnEmptyString, 'B');
74 addThis();
76 status = inSection(7);
77 pattern = /(\S+)?(!?)(.*)/;
78 string = 'WOW !!! !!!';
79 actualmatch = string.match(pattern);
80 expectedmatch = Array(string, 'WOW', cnEmptyString, ' !!! !!!');
81 addThis();
83 status = inSection(8);
84 pattern = /(.+)?(!?)(!+)/;
85 string = 'WOW !!! !!!';
86 actualmatch = string.match(pattern);
87 expectedmatch = Array(string, 'WOW !!! !!', cnEmptyString, '!');
88 addThis();
92 //-----------------------------------------------------------------------------
93 test();
94 //-----------------------------------------------------------------------------
98 function addThis()
99 {
100 statusmessages[i] = status;
101 patterns[i] = pattern;
102 strings[i] = string;
103 actualmatches[i] = actualmatch;
104 expectedmatches[i] = expectedmatch;
105 i++;
106 }
109 function test()
110 {
111 enterFunc ('test');
112 printBugNumber(BUGNUMBER);
113 printStatus (summary);
114 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
115 exitFunc ('test');
116 }