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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* |
michael@0 | 7 | * Date: 28 December 2000 |
michael@0 | 8 | * |
michael@0 | 9 | * SUMMARY: Testing regular expressions containing the ? character. |
michael@0 | 10 | * Arose from Bugzilla bug 57572: "RegExp with ? matches incorrectly" |
michael@0 | 11 | * |
michael@0 | 12 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=57572 |
michael@0 | 13 | * |
michael@0 | 14 | */ |
michael@0 | 15 | //----------------------------------------------------------------------------- |
michael@0 | 16 | var i = 0; |
michael@0 | 17 | var BUGNUMBER = 57572; |
michael@0 | 18 | var summary = 'Testing regular expressions containing "?"'; |
michael@0 | 19 | var cnEmptyString = ''; var cnSingleSpace = ' '; |
michael@0 | 20 | var status = ''; |
michael@0 | 21 | var statusmessages = new Array(); |
michael@0 | 22 | var pattern = ''; |
michael@0 | 23 | var patterns = new Array(); |
michael@0 | 24 | var string = ''; |
michael@0 | 25 | var strings = new Array(); |
michael@0 | 26 | var actualmatch = ''; |
michael@0 | 27 | var actualmatches = new Array(); |
michael@0 | 28 | var expectedmatch = ''; |
michael@0 | 29 | var expectedmatches = new Array(); |
michael@0 | 30 | |
michael@0 | 31 | |
michael@0 | 32 | status = inSection(1); |
michael@0 | 33 | pattern = /(\S+)?(.*)/; |
michael@0 | 34 | string = 'Test this'; |
michael@0 | 35 | actualmatch = string.match(pattern); |
michael@0 | 36 | expectedmatch = Array(string, 'Test', ' this'); //single space in front of 'this' |
michael@0 | 37 | addThis(); |
michael@0 | 38 | |
michael@0 | 39 | status = inSection(2); |
michael@0 | 40 | pattern = /(\S+)? ?(.*)/; //single space between the ? characters |
michael@0 | 41 | string= 'Test this'; |
michael@0 | 42 | actualmatch = string.match(pattern); |
michael@0 | 43 | expectedmatch = Array(string, 'Test', 'this'); //NO space in front of 'this' |
michael@0 | 44 | addThis(); |
michael@0 | 45 | |
michael@0 | 46 | status = inSection(3); |
michael@0 | 47 | pattern = /(\S+)?(.*)/; |
michael@0 | 48 | string = 'Stupid phrase, with six - (short) words'; |
michael@0 | 49 | actualmatch = string.match(pattern); |
michael@0 | 50 | expectedmatch = Array(string, 'Stupid', ' phrase, with six - (short) words'); //single space in front of 'phrase' |
michael@0 | 51 | addThis(); |
michael@0 | 52 | |
michael@0 | 53 | status = inSection(4); |
michael@0 | 54 | pattern = /(\S+)? ?(.*)/; //single space between the ? characters |
michael@0 | 55 | string = 'Stupid phrase, with six - (short) words'; |
michael@0 | 56 | actualmatch = string.match(pattern); |
michael@0 | 57 | expectedmatch = Array(string, 'Stupid', 'phrase, with six - (short) words'); //NO space in front of 'phrase' |
michael@0 | 58 | addThis(); |
michael@0 | 59 | |
michael@0 | 60 | |
michael@0 | 61 | // let's add an extra back-reference this time - three instead of two - |
michael@0 | 62 | status = inSection(5); |
michael@0 | 63 | pattern = /(\S+)?( ?)(.*)/; //single space before second ? character |
michael@0 | 64 | string = 'Stupid phrase, with six - (short) words'; |
michael@0 | 65 | actualmatch = string.match(pattern); |
michael@0 | 66 | expectedmatch = Array(string, 'Stupid', cnSingleSpace, 'phrase, with six - (short) words'); |
michael@0 | 67 | addThis(); |
michael@0 | 68 | |
michael@0 | 69 | status = inSection(6); |
michael@0 | 70 | pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character |
michael@0 | 71 | string = 'AAABBB'; |
michael@0 | 72 | actualmatch = string.match(pattern); |
michael@0 | 73 | expectedmatch = Array(string, 'AAABB', cnEmptyString, 'B'); |
michael@0 | 74 | addThis(); |
michael@0 | 75 | |
michael@0 | 76 | status = inSection(7); |
michael@0 | 77 | pattern = /(\S+)?(!?)(.*)/; |
michael@0 | 78 | string = 'WOW !!! !!!'; |
michael@0 | 79 | actualmatch = string.match(pattern); |
michael@0 | 80 | expectedmatch = Array(string, 'WOW', cnEmptyString, ' !!! !!!'); |
michael@0 | 81 | addThis(); |
michael@0 | 82 | |
michael@0 | 83 | status = inSection(8); |
michael@0 | 84 | pattern = /(.+)?(!?)(!+)/; |
michael@0 | 85 | string = 'WOW !!! !!!'; |
michael@0 | 86 | actualmatch = string.match(pattern); |
michael@0 | 87 | expectedmatch = Array(string, 'WOW !!! !!', cnEmptyString, '!'); |
michael@0 | 88 | addThis(); |
michael@0 | 89 | |
michael@0 | 90 | |
michael@0 | 91 | |
michael@0 | 92 | //----------------------------------------------------------------------------- |
michael@0 | 93 | test(); |
michael@0 | 94 | //----------------------------------------------------------------------------- |
michael@0 | 95 | |
michael@0 | 96 | |
michael@0 | 97 | |
michael@0 | 98 | function addThis() |
michael@0 | 99 | { |
michael@0 | 100 | statusmessages[i] = status; |
michael@0 | 101 | patterns[i] = pattern; |
michael@0 | 102 | strings[i] = string; |
michael@0 | 103 | actualmatches[i] = actualmatch; |
michael@0 | 104 | expectedmatches[i] = expectedmatch; |
michael@0 | 105 | i++; |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | |
michael@0 | 109 | function test() |
michael@0 | 110 | { |
michael@0 | 111 | enterFunc ('test'); |
michael@0 | 112 | printBugNumber(BUGNUMBER); |
michael@0 | 113 | printStatus (summary); |
michael@0 | 114 | testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); |
michael@0 | 115 | exitFunc ('test'); |
michael@0 | 116 | } |