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: 22 October 2001 |
michael@0 | 8 | * |
michael@0 | 9 | * SUMMARY: Regression test for Bugzilla bug 105972: |
michael@0 | 10 | * "/^.*?$/ will not match anything" |
michael@0 | 11 | * |
michael@0 | 12 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=105972 |
michael@0 | 13 | */ |
michael@0 | 14 | //----------------------------------------------------------------------------- |
michael@0 | 15 | var i = 0; |
michael@0 | 16 | var BUGNUMBER = 105972; |
michael@0 | 17 | var summary = 'Regression test for Bugzilla bug 105972'; |
michael@0 | 18 | var cnEmptyString = ''; |
michael@0 | 19 | var status = ''; |
michael@0 | 20 | var statusmessages = new Array(); |
michael@0 | 21 | var pattern = ''; |
michael@0 | 22 | var patterns = new Array(); |
michael@0 | 23 | var string = ''; |
michael@0 | 24 | var strings = new Array(); |
michael@0 | 25 | var actualmatch = ''; |
michael@0 | 26 | var actualmatches = new Array(); |
michael@0 | 27 | var expectedmatch = ''; |
michael@0 | 28 | var expectedmatches = new Array(); |
michael@0 | 29 | |
michael@0 | 30 | |
michael@0 | 31 | /* |
michael@0 | 32 | * The bug: this match was coming up null in Rhino and SpiderMonkey. |
michael@0 | 33 | * It should match the whole string. The reason: |
michael@0 | 34 | * |
michael@0 | 35 | * The * operator is greedy, but *? is non-greedy: it will stop |
michael@0 | 36 | * at the simplest match it can find. But the pattern here asks us |
michael@0 | 37 | * to match till the end of the string. So the simplest match must |
michael@0 | 38 | * go all the way out to the end, and *? has no choice but to do it. |
michael@0 | 39 | */ |
michael@0 | 40 | status = inSection(1); |
michael@0 | 41 | pattern = /^.*?$/; |
michael@0 | 42 | string = 'Hello World'; |
michael@0 | 43 | actualmatch = string.match(pattern); |
michael@0 | 44 | expectedmatch = Array(string); |
michael@0 | 45 | addThis(); |
michael@0 | 46 | |
michael@0 | 47 | |
michael@0 | 48 | /* |
michael@0 | 49 | * Leave off the '$' condition - here we expect the empty string. |
michael@0 | 50 | * Unlike the above pattern, we don't have to match till the end of |
michael@0 | 51 | * the string, so the non-greedy operator *? doesn't try to... |
michael@0 | 52 | */ |
michael@0 | 53 | status = inSection(2); |
michael@0 | 54 | pattern = /^.*?/; |
michael@0 | 55 | string = 'Hello World'; |
michael@0 | 56 | actualmatch = string.match(pattern); |
michael@0 | 57 | expectedmatch = Array(cnEmptyString); |
michael@0 | 58 | addThis(); |
michael@0 | 59 | |
michael@0 | 60 | |
michael@0 | 61 | /* |
michael@0 | 62 | * Try '$' combined with an 'or' operator. |
michael@0 | 63 | * |
michael@0 | 64 | * The operator *? will consume the string from left to right, |
michael@0 | 65 | * attempting to satisfy the condition (:|$). When it hits ':', |
michael@0 | 66 | * the match will stop because the operator *? is non-greedy. |
michael@0 | 67 | * |
michael@0 | 68 | * The submatch $1 = (:|$) will contain the ':' |
michael@0 | 69 | */ |
michael@0 | 70 | status = inSection(3); |
michael@0 | 71 | pattern = /^.*?(:|$)/; |
michael@0 | 72 | string = 'Hello: World'; |
michael@0 | 73 | actualmatch = string.match(pattern); |
michael@0 | 74 | expectedmatch = Array('Hello:', ':'); |
michael@0 | 75 | addThis(); |
michael@0 | 76 | |
michael@0 | 77 | |
michael@0 | 78 | /* |
michael@0 | 79 | * Again, '$' combined with an 'or' operator. |
michael@0 | 80 | * |
michael@0 | 81 | * The operator * will consume the string from left to right, |
michael@0 | 82 | * attempting to satisfy the condition (:|$). When it hits ':', |
michael@0 | 83 | * the match will not stop since * is greedy. The match will |
michael@0 | 84 | * continue until it hits $, the end-of-string boundary. |
michael@0 | 85 | * |
michael@0 | 86 | * The submatch $1 = (:|$) will contain the empty string |
michael@0 | 87 | * conceived to exist at the end-of-string boundary. |
michael@0 | 88 | */ |
michael@0 | 89 | status = inSection(4); |
michael@0 | 90 | pattern = /^.*(:|$)/; |
michael@0 | 91 | string = 'Hello: World'; |
michael@0 | 92 | actualmatch = string.match(pattern); |
michael@0 | 93 | expectedmatch = Array(string, cnEmptyString); |
michael@0 | 94 | addThis(); |
michael@0 | 95 | |
michael@0 | 96 | |
michael@0 | 97 | |
michael@0 | 98 | |
michael@0 | 99 | //----------------------------------------------------------------------------- |
michael@0 | 100 | test(); |
michael@0 | 101 | //----------------------------------------------------------------------------- |
michael@0 | 102 | |
michael@0 | 103 | |
michael@0 | 104 | |
michael@0 | 105 | function addThis() |
michael@0 | 106 | { |
michael@0 | 107 | statusmessages[i] = status; |
michael@0 | 108 | patterns[i] = pattern; |
michael@0 | 109 | strings[i] = string; |
michael@0 | 110 | actualmatches[i] = actualmatch; |
michael@0 | 111 | expectedmatches[i] = expectedmatch; |
michael@0 | 112 | i++; |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | |
michael@0 | 116 | function test() |
michael@0 | 117 | { |
michael@0 | 118 | enterFunc ('test'); |
michael@0 | 119 | printBugNumber(BUGNUMBER); |
michael@0 | 120 | printStatus (summary); |
michael@0 | 121 | testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); |
michael@0 | 122 | exitFunc ('test'); |
michael@0 | 123 | } |