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 | var BUGNUMBER = 321874; |
michael@0 | 8 | var summary = 'lhs must be a reference in (for lhs in rhs) ...'; |
michael@0 | 9 | var actual = ''; |
michael@0 | 10 | var expect = ''; |
michael@0 | 11 | var section; |
michael@0 | 12 | |
michael@0 | 13 | printBugNumber(BUGNUMBER); |
michael@0 | 14 | printStatus (summary); |
michael@0 | 15 | |
michael@0 | 16 | function a() {} |
michael@0 | 17 | var b = {foo: 'bar'}; |
michael@0 | 18 | |
michael@0 | 19 | printStatus('for-in tests'); |
michael@0 | 20 | |
michael@0 | 21 | var v; |
michael@0 | 22 | section = summary + ': for((v) in b);'; |
michael@0 | 23 | expect = 'foo'; |
michael@0 | 24 | printStatus(section); |
michael@0 | 25 | try |
michael@0 | 26 | { |
michael@0 | 27 | eval('for ((v) in b);'); |
michael@0 | 28 | actual = v; |
michael@0 | 29 | } |
michael@0 | 30 | catch(ex) |
michael@0 | 31 | { |
michael@0 | 32 | printStatus(ex+''); |
michael@0 | 33 | actual = 'error'; |
michael@0 | 34 | } |
michael@0 | 35 | reportCompare(expect, actual, section); |
michael@0 | 36 | |
michael@0 | 37 | section = summary + ': function foo(){for((v) in b);};foo();'; |
michael@0 | 38 | expect = 'foo'; |
michael@0 | 39 | printStatus(section); |
michael@0 | 40 | try |
michael@0 | 41 | { |
michael@0 | 42 | eval('function foo(){ for ((v) in b);}; foo();'); |
michael@0 | 43 | actual = v; |
michael@0 | 44 | } |
michael@0 | 45 | catch(ex) |
michael@0 | 46 | { |
michael@0 | 47 | printStatus(ex+''); |
michael@0 | 48 | actual = 'error'; |
michael@0 | 49 | } |
michael@0 | 50 | reportCompare(expect, actual, section); |
michael@0 | 51 | |
michael@0 | 52 | section = summary + ': for(a() in b);'; |
michael@0 | 53 | expect = 'error'; |
michael@0 | 54 | printStatus(section); |
michael@0 | 55 | try |
michael@0 | 56 | { |
michael@0 | 57 | eval('for (a() in b);'); |
michael@0 | 58 | actual = 'no error'; |
michael@0 | 59 | } |
michael@0 | 60 | catch(ex) |
michael@0 | 61 | { |
michael@0 | 62 | printStatus(ex+''); |
michael@0 | 63 | actual = 'error'; |
michael@0 | 64 | } |
michael@0 | 65 | reportCompare(expect, actual, section); |
michael@0 | 66 | |
michael@0 | 67 | section = summary + ': function foo(){for(a() in b);};foo();'; |
michael@0 | 68 | expect = 'error'; |
michael@0 | 69 | printStatus(section); |
michael@0 | 70 | try |
michael@0 | 71 | { |
michael@0 | 72 | eval('function foo(){ for (a() in b);};foo();'); |
michael@0 | 73 | actual = 'no error'; |
michael@0 | 74 | } |
michael@0 | 75 | catch(ex) |
michael@0 | 76 | { |
michael@0 | 77 | printStatus(ex+''); |
michael@0 | 78 | actual = 'error'; |
michael@0 | 79 | } |
michael@0 | 80 | reportCompare(expect, actual, section); |
michael@0 | 81 | |
michael@0 | 82 | section = ': for(new a() in b);'; |
michael@0 | 83 | expect = 'error'; |
michael@0 | 84 | printStatus(section); |
michael@0 | 85 | try |
michael@0 | 86 | { |
michael@0 | 87 | eval('for (new a() in b);'); |
michael@0 | 88 | actual = 'no error'; |
michael@0 | 89 | } |
michael@0 | 90 | catch(ex) |
michael@0 | 91 | { |
michael@0 | 92 | printStatus(ex+''); |
michael@0 | 93 | actual = 'error'; |
michael@0 | 94 | } |
michael@0 | 95 | reportCompare(expect, actual, summary + section); |
michael@0 | 96 | |
michael@0 | 97 | section = ': function foo(){for(new a() in b);};foo();'; |
michael@0 | 98 | expect = 'error'; |
michael@0 | 99 | printStatus(section); |
michael@0 | 100 | try |
michael@0 | 101 | { |
michael@0 | 102 | eval('function foo(){ for (new a() in b);};foo();'); |
michael@0 | 103 | actual = 'no error'; |
michael@0 | 104 | } |
michael@0 | 105 | catch(ex) |
michael@0 | 106 | { |
michael@0 | 107 | printStatus(ex+''); |
michael@0 | 108 | actual = 'error'; |
michael@0 | 109 | } |
michael@0 | 110 | reportCompare(expect, actual, summary + section); |
michael@0 | 111 | |
michael@0 | 112 | section = ': for(void in b);'; |
michael@0 | 113 | expect = 'error'; |
michael@0 | 114 | printStatus(section); |
michael@0 | 115 | try |
michael@0 | 116 | { |
michael@0 | 117 | eval('for (void in b);'); |
michael@0 | 118 | actual = 'no error'; |
michael@0 | 119 | } |
michael@0 | 120 | catch(ex) |
michael@0 | 121 | { |
michael@0 | 122 | printStatus(ex+''); |
michael@0 | 123 | actual = 'error'; |
michael@0 | 124 | } |
michael@0 | 125 | reportCompare(expect, actual, summary + section); |
michael@0 | 126 | |
michael@0 | 127 | section = ': function foo(){for(void in b);};foo();'; |
michael@0 | 128 | expect = 'error'; |
michael@0 | 129 | printStatus(section); |
michael@0 | 130 | try |
michael@0 | 131 | { |
michael@0 | 132 | eval('function foo(){ for (void in b);};foo();'); |
michael@0 | 133 | actual = 'no error'; |
michael@0 | 134 | } |
michael@0 | 135 | catch(ex) |
michael@0 | 136 | { |
michael@0 | 137 | printStatus(ex+''); |
michael@0 | 138 | actual = 'error'; |
michael@0 | 139 | } |
michael@0 | 140 | reportCompare(expect, actual, summary + section); |
michael@0 | 141 | |
michael@0 | 142 | var d = 1; |
michael@0 | 143 | var e = 2; |
michael@0 | 144 | expect = 'error'; |
michael@0 | 145 | section = ': for((d*e) in b);'; |
michael@0 | 146 | printStatus(section); |
michael@0 | 147 | try |
michael@0 | 148 | { |
michael@0 | 149 | eval('for ((d*e) in b);'); |
michael@0 | 150 | actual = 'no error'; |
michael@0 | 151 | } |
michael@0 | 152 | catch(ex) |
michael@0 | 153 | { |
michael@0 | 154 | printStatus(ex+''); |
michael@0 | 155 | actual = 'error'; |
michael@0 | 156 | } |
michael@0 | 157 | reportCompare(expect, actual, summary + section); |
michael@0 | 158 | |
michael@0 | 159 | var d = 1; |
michael@0 | 160 | var e = 2; |
michael@0 | 161 | expect = 'error'; |
michael@0 | 162 | section = ': function foo(){for((d*e) in b);};foo();'; |
michael@0 | 163 | printStatus(section); |
michael@0 | 164 | try |
michael@0 | 165 | { |
michael@0 | 166 | eval('function foo(){ for ((d*e) in b);};foo();'); |
michael@0 | 167 | actual = 'no error'; |
michael@0 | 168 | } |
michael@0 | 169 | catch(ex) |
michael@0 | 170 | { |
michael@0 | 171 | printStatus(ex+''); |
michael@0 | 172 | actual = 'error'; |
michael@0 | 173 | } |
michael@0 | 174 | reportCompare(expect, actual, summary + section); |
michael@0 | 175 | |
michael@0 | 176 | const c = 0; |
michael@0 | 177 | expect = 0; |
michael@0 | 178 | section = ': for(c in b);'; |
michael@0 | 179 | printStatus(section); |
michael@0 | 180 | try |
michael@0 | 181 | { |
michael@0 | 182 | eval('for (c in b);'); |
michael@0 | 183 | actual = c; |
michael@0 | 184 | printStatus('typeof c: ' + (typeof c) + ', c: ' + c); |
michael@0 | 185 | } |
michael@0 | 186 | catch(ex) |
michael@0 | 187 | { |
michael@0 | 188 | printStatus(ex+''); |
michael@0 | 189 | actual = 'error'; |
michael@0 | 190 | } |
michael@0 | 191 | reportCompare(expect, actual, summary + section); |
michael@0 | 192 | |
michael@0 | 193 | expect = 0; |
michael@0 | 194 | section = ': function foo(){for(c in b);};foo();'; |
michael@0 | 195 | printStatus(section); |
michael@0 | 196 | try |
michael@0 | 197 | { |
michael@0 | 198 | eval('function foo(){ for (c in b);};foo();'); |
michael@0 | 199 | actual = c; |
michael@0 | 200 | printStatus('typeof c: ' + (typeof c) + ', c: ' + c); |
michael@0 | 201 | } |
michael@0 | 202 | catch(ex) |
michael@0 | 203 | { |
michael@0 | 204 | printStatus(ex+''); |
michael@0 | 205 | actual = 'error'; |
michael@0 | 206 | } |
michael@0 | 207 | reportCompare(expect, actual, summary + section); |