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 | /** |
michael@0 | 8 | * File Name: RegExp/exec-002.js |
michael@0 | 9 | * ECMA Section: 15.7.5.3 |
michael@0 | 10 | * Description: Based on ECMA 2 Draft 7 February 1999 |
michael@0 | 11 | * |
michael@0 | 12 | * Test cases provided by rogerl@netscape.com |
michael@0 | 13 | * |
michael@0 | 14 | * Author: christine@netscape.com |
michael@0 | 15 | * Date: 19 February 1999 |
michael@0 | 16 | */ |
michael@0 | 17 | var SECTION = "RegExp/exec-002"; |
michael@0 | 18 | var VERSION = "ECMA_2"; |
michael@0 | 19 | var TITLE = "RegExp.prototype.exec(string)"; |
michael@0 | 20 | |
michael@0 | 21 | startTest(); |
michael@0 | 22 | |
michael@0 | 23 | /* |
michael@0 | 24 | * for each test case, verify: |
michael@0 | 25 | * - type of object returned |
michael@0 | 26 | * - length of the returned array |
michael@0 | 27 | * - value of lastIndex |
michael@0 | 28 | * - value of index |
michael@0 | 29 | * - value of input |
michael@0 | 30 | * - value of the array indices |
michael@0 | 31 | */ |
michael@0 | 32 | |
michael@0 | 33 | AddRegExpCases( |
michael@0 | 34 | /(a|d|q|)x/i, |
michael@0 | 35 | "bcaDxqy", |
michael@0 | 36 | 3, |
michael@0 | 37 | ["Dx", "D"] ); |
michael@0 | 38 | |
michael@0 | 39 | AddRegExpCases( |
michael@0 | 40 | /(a|(e|q))(x|y)/, |
michael@0 | 41 | "bcaddxqy", |
michael@0 | 42 | 6, |
michael@0 | 43 | ["qy","q","q","y"] ); |
michael@0 | 44 | |
michael@0 | 45 | |
michael@0 | 46 | AddRegExpCases( |
michael@0 | 47 | /a+b+d/, |
michael@0 | 48 | "aabbeeaabbs", |
michael@0 | 49 | 0, |
michael@0 | 50 | null ); |
michael@0 | 51 | |
michael@0 | 52 | AddRegExpCases( |
michael@0 | 53 | /a*b/, |
michael@0 | 54 | "aaadaabaaa", |
michael@0 | 55 | 4, |
michael@0 | 56 | ["aab"] ); |
michael@0 | 57 | |
michael@0 | 58 | AddRegExpCases( |
michael@0 | 59 | /a*b/, |
michael@0 | 60 | "dddb", |
michael@0 | 61 | 3, |
michael@0 | 62 | ["b"] ); |
michael@0 | 63 | |
michael@0 | 64 | AddRegExpCases( |
michael@0 | 65 | /a*b/, |
michael@0 | 66 | "xxx", |
michael@0 | 67 | 0, |
michael@0 | 68 | null ); |
michael@0 | 69 | |
michael@0 | 70 | AddRegExpCases( |
michael@0 | 71 | /x\d\dy/, |
michael@0 | 72 | "abcx45ysss235", |
michael@0 | 73 | 3, |
michael@0 | 74 | ["x45y"] ); |
michael@0 | 75 | |
michael@0 | 76 | AddRegExpCases( |
michael@0 | 77 | /[^abc]def[abc]+/, |
michael@0 | 78 | "abxdefbb", |
michael@0 | 79 | 2, |
michael@0 | 80 | ["xdefbb"] ); |
michael@0 | 81 | |
michael@0 | 82 | AddRegExpCases( |
michael@0 | 83 | /(a*)baa/, |
michael@0 | 84 | "ccdaaabaxaabaa", |
michael@0 | 85 | 9, |
michael@0 | 86 | ["aabaa", "aa"] ); |
michael@0 | 87 | |
michael@0 | 88 | AddRegExpCases( |
michael@0 | 89 | /(a*)baa/, |
michael@0 | 90 | "aabaa", |
michael@0 | 91 | 0, |
michael@0 | 92 | ["aabaa", "aa"] ); |
michael@0 | 93 | |
michael@0 | 94 | AddRegExpCases( |
michael@0 | 95 | /q(a|b)*q/, |
michael@0 | 96 | "xxqababqyy", |
michael@0 | 97 | 2, |
michael@0 | 98 | ["qababq", "b"] ); |
michael@0 | 99 | |
michael@0 | 100 | AddRegExpCases( |
michael@0 | 101 | /(a(.|[^d])c)*/, |
michael@0 | 102 | "adcaxc", |
michael@0 | 103 | 0, |
michael@0 | 104 | ["adcaxc", "axc", "x"] ); |
michael@0 | 105 | |
michael@0 | 106 | AddRegExpCases( |
michael@0 | 107 | /(a*)b\1/, |
michael@0 | 108 | "abaaaxaabaayy", |
michael@0 | 109 | 0, |
michael@0 | 110 | ["aba", "a"] ); |
michael@0 | 111 | |
michael@0 | 112 | AddRegExpCases( |
michael@0 | 113 | /(a*)b\1/, |
michael@0 | 114 | "abaaaxaabaayy", |
michael@0 | 115 | 0, |
michael@0 | 116 | ["aba", "a"] ); |
michael@0 | 117 | |
michael@0 | 118 | AddRegExpCases( |
michael@0 | 119 | /(a*)b\1/, |
michael@0 | 120 | "cccdaaabaxaabaayy", |
michael@0 | 121 | 6, |
michael@0 | 122 | ["aba", "a"] ); |
michael@0 | 123 | |
michael@0 | 124 | AddRegExpCases( |
michael@0 | 125 | /(a*)b\1/, |
michael@0 | 126 | "cccdaaabqxaabaayy", |
michael@0 | 127 | 7, |
michael@0 | 128 | ["b", ""] ); |
michael@0 | 129 | |
michael@0 | 130 | AddRegExpCases( |
michael@0 | 131 | /"(.|[^"\\\\])*"/, |
michael@0 | 132 | 'xx\"makudonarudo\"yy', |
michael@0 | 133 | 2, |
michael@0 | 134 | ["\"makudonarudo\"", "o"] ); |
michael@0 | 135 | |
michael@0 | 136 | AddRegExpCases( |
michael@0 | 137 | /"(.|[^"\\\\])*"/, |
michael@0 | 138 | "xx\"ma\"yy", |
michael@0 | 139 | 2, |
michael@0 | 140 | ["\"ma\"", "a"] ); |
michael@0 | 141 | |
michael@0 | 142 | test(); |
michael@0 | 143 | |
michael@0 | 144 | function AddRegExpCases( |
michael@0 | 145 | regexp, pattern, index, matches_array ) { |
michael@0 | 146 | |
michael@0 | 147 | // prevent a runtime error |
michael@0 | 148 | |
michael@0 | 149 | if ( regexp.exec(pattern) == null || matches_array == null ) { |
michael@0 | 150 | AddTestCase( |
michael@0 | 151 | regexp + ".exec(" + pattern +")", |
michael@0 | 152 | matches_array, |
michael@0 | 153 | regexp.exec(pattern) ); |
michael@0 | 154 | |
michael@0 | 155 | return; |
michael@0 | 156 | } |
michael@0 | 157 | AddTestCase( |
michael@0 | 158 | regexp + ".exec(" + pattern +").length", |
michael@0 | 159 | matches_array.length, |
michael@0 | 160 | regexp.exec(pattern).length ); |
michael@0 | 161 | |
michael@0 | 162 | AddTestCase( |
michael@0 | 163 | regexp + ".exec(" + pattern +").index", |
michael@0 | 164 | index, |
michael@0 | 165 | regexp.exec(pattern).index ); |
michael@0 | 166 | |
michael@0 | 167 | AddTestCase( |
michael@0 | 168 | regexp + ".exec(" + pattern +").input", |
michael@0 | 169 | pattern, |
michael@0 | 170 | regexp.exec(pattern).input ); |
michael@0 | 171 | |
michael@0 | 172 | AddTestCase( |
michael@0 | 173 | regexp + ".exec(" + pattern +").toString()", |
michael@0 | 174 | matches_array.toString(), |
michael@0 | 175 | regexp.exec(pattern).toString() ); |
michael@0 | 176 | /* |
michael@0 | 177 | var limit = matches_array.length > regexp.exec(pattern).length |
michael@0 | 178 | ? matches_array.length |
michael@0 | 179 | : regexp.exec(pattern).length; |
michael@0 | 180 | |
michael@0 | 181 | for ( var matches = 0; matches < limit; matches++ ) { |
michael@0 | 182 | AddTestCase( |
michael@0 | 183 | regexp + ".exec(" + pattern +")[" + matches +"]", |
michael@0 | 184 | matches_array[matches], |
michael@0 | 185 | regexp.exec(pattern)[matches] ); |
michael@0 | 186 | } |
michael@0 | 187 | */ |
michael@0 | 188 | } |