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: forin-001.js |
michael@0 | 9 | * ECMA Section: |
michael@0 | 10 | * Description: The forin-001 statement |
michael@0 | 11 | * |
michael@0 | 12 | * Verify that the property name is assigned to the property on the left |
michael@0 | 13 | * hand side of the for...in expression. |
michael@0 | 14 | * |
michael@0 | 15 | * Author: christine@netscape.com |
michael@0 | 16 | * Date: 28 August 1998 |
michael@0 | 17 | */ |
michael@0 | 18 | var SECTION = "forin-001"; |
michael@0 | 19 | var VERSION = "ECMA_2"; |
michael@0 | 20 | var TITLE = "The for...in statement"; |
michael@0 | 21 | var BUGNUMBER="330890"; |
michael@0 | 22 | var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; |
michael@0 | 23 | |
michael@0 | 24 | startTest(); |
michael@0 | 25 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 26 | |
michael@0 | 27 | ForIn_1( { length:4, company:"netscape", year:2000, 0:"zero" } ); |
michael@0 | 28 | ForIn_2( { length:4, company:"netscape", year:2000, 0:"zero" } ); |
michael@0 | 29 | ForIn_3( { length:4, company:"netscape", year:2000, 0:"zero" } ); |
michael@0 | 30 | |
michael@0 | 31 | // ForIn_6({ length:4, company:"netscape", year:2000, 0:"zero" }); |
michael@0 | 32 | // ForIn_7({ length:4, company:"netscape", year:2000, 0:"zero" }); |
michael@0 | 33 | ForIn_8({ length:4, company:"netscape", year:2000, 0:"zero" }); |
michael@0 | 34 | |
michael@0 | 35 | test(); |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * Verify that the left side argument is evaluated with every iteration. |
michael@0 | 39 | * Verify that the name of each property of the object is assigned to a |
michael@0 | 40 | * a property. |
michael@0 | 41 | * |
michael@0 | 42 | */ |
michael@0 | 43 | function ForIn_1( object ) { |
michael@0 | 44 | PropertyArray = new Array(); |
michael@0 | 45 | ValueArray = new Array(); |
michael@0 | 46 | |
michael@0 | 47 | for ( PropertyArray[PropertyArray.length] in object ) { |
michael@0 | 48 | ValueArray[ValueArray.length] = |
michael@0 | 49 | object[PropertyArray[PropertyArray.length-1]]; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | for ( var i = 0; i < PropertyArray.length; i++ ) { |
michael@0 | 53 | new TestCase( |
michael@0 | 54 | SECTION, |
michael@0 | 55 | "object[" + PropertyArray[i] +"]", |
michael@0 | 56 | object[PropertyArray[i]], |
michael@0 | 57 | ValueArray[i] |
michael@0 | 58 | ); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | new TestCase( |
michael@0 | 62 | SECTION, |
michael@0 | 63 | "object.length", |
michael@0 | 64 | PropertyArray.length, |
michael@0 | 65 | object.length ); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | /** |
michael@0 | 69 | * Similar to ForIn_1, except it should increment the counter variable |
michael@0 | 70 | * every time the left hand expression is evaluated. |
michael@0 | 71 | */ |
michael@0 | 72 | function ForIn_2( object ) { |
michael@0 | 73 | PropertyArray = new Array(); |
michael@0 | 74 | ValueArray = new Array(); |
michael@0 | 75 | var i = 0; |
michael@0 | 76 | |
michael@0 | 77 | for ( PropertyArray[i++] in object ) { |
michael@0 | 78 | ValueArray[ValueArray.length] = |
michael@0 | 79 | object[PropertyArray[PropertyArray.length-1]]; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | for ( i = 0; i < PropertyArray.length; i++ ) { |
michael@0 | 83 | new TestCase( |
michael@0 | 84 | SECTION, |
michael@0 | 85 | "object[" + PropertyArray[i] +"]", |
michael@0 | 86 | object[PropertyArray[i]], |
michael@0 | 87 | ValueArray[i] |
michael@0 | 88 | ); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | new TestCase( |
michael@0 | 92 | SECTION, |
michael@0 | 93 | "object.length", |
michael@0 | 94 | PropertyArray.length, |
michael@0 | 95 | object.length ); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | /** |
michael@0 | 99 | * Break out of a for...in loop |
michael@0 | 100 | * |
michael@0 | 101 | * |
michael@0 | 102 | */ |
michael@0 | 103 | function ForIn_3( object ) { |
michael@0 | 104 | var checkBreak = "pass"; |
michael@0 | 105 | var properties = new Array(); |
michael@0 | 106 | var values = new Array(); |
michael@0 | 107 | |
michael@0 | 108 | for ( properties[properties.length] in object ) { |
michael@0 | 109 | values[values.length] = object[properties[properties.length-1]]; |
michael@0 | 110 | break; |
michael@0 | 111 | checkBreak = "fail"; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | new TestCase( |
michael@0 | 115 | SECTION, |
michael@0 | 116 | "check break out of for...in", |
michael@0 | 117 | "pass", |
michael@0 | 118 | checkBreak ); |
michael@0 | 119 | |
michael@0 | 120 | new TestCase( |
michael@0 | 121 | SECTION, |
michael@0 | 122 | "properties.length", |
michael@0 | 123 | 1, |
michael@0 | 124 | properties.length ); |
michael@0 | 125 | |
michael@0 | 126 | new TestCase( |
michael@0 | 127 | SECTION, |
michael@0 | 128 | "object["+properties[0]+"]", |
michael@0 | 129 | values[0], |
michael@0 | 130 | object[properties[0]] ); |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | /** |
michael@0 | 134 | * Break out of a labeled for...in loop. |
michael@0 | 135 | */ |
michael@0 | 136 | function ForIn_4( object ) { |
michael@0 | 137 | var result1 = 0; |
michael@0 | 138 | var result2 = 0; |
michael@0 | 139 | var result3 = 0; |
michael@0 | 140 | var result4 = 0; |
michael@0 | 141 | var i = 0; |
michael@0 | 142 | var property = new Array(); |
michael@0 | 143 | |
michael@0 | 144 | butterbean: { |
michael@0 | 145 | result1++; |
michael@0 | 146 | |
michael@0 | 147 | for ( property[i++] in object ) { |
michael@0 | 148 | result2++; |
michael@0 | 149 | break; |
michael@0 | 150 | result4++; |
michael@0 | 151 | } |
michael@0 | 152 | result3++; |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | new TestCase( |
michael@0 | 156 | SECTION, |
michael@0 | 157 | "verify labeled statement is only executed once", |
michael@0 | 158 | true, |
michael@0 | 159 | result1 == 1 ); |
michael@0 | 160 | |
michael@0 | 161 | new TestCase( |
michael@0 | 162 | SECTION, |
michael@0 | 163 | "verify statements in for loop are evaluated", |
michael@0 | 164 | true, |
michael@0 | 165 | result2 == i ); |
michael@0 | 166 | |
michael@0 | 167 | new TestCase( |
michael@0 | 168 | SECTION, |
michael@0 | 169 | "verify break out of labeled for...in loop", |
michael@0 | 170 | true, |
michael@0 | 171 | result4 == 0 ); |
michael@0 | 172 | |
michael@0 | 173 | new TestCase( |
michael@0 | 174 | SECTION, |
michael@0 | 175 | "verify break out of labeled block", |
michael@0 | 176 | true, |
michael@0 | 177 | result3 == 0 ); |
michael@0 | 178 | } |
michael@0 | 179 | |
michael@0 | 180 | /** |
michael@0 | 181 | * Labeled break out of a labeled for...in loop. |
michael@0 | 182 | */ |
michael@0 | 183 | function ForIn_5 (object) { |
michael@0 | 184 | var result1 = 0; |
michael@0 | 185 | var result2 = 0; |
michael@0 | 186 | var result3 = 0; |
michael@0 | 187 | var result4 = 0; |
michael@0 | 188 | var i = 0; |
michael@0 | 189 | var property = new Array(); |
michael@0 | 190 | |
michael@0 | 191 | bigredbird: { |
michael@0 | 192 | result1++; |
michael@0 | 193 | for ( property[i++] in object ) { |
michael@0 | 194 | result2++; |
michael@0 | 195 | break bigredbird; |
michael@0 | 196 | result4++; |
michael@0 | 197 | } |
michael@0 | 198 | result3++; |
michael@0 | 199 | } |
michael@0 | 200 | |
michael@0 | 201 | new TestCase( |
michael@0 | 202 | SECTION, |
michael@0 | 203 | "verify labeled statement is only executed once", |
michael@0 | 204 | true, |
michael@0 | 205 | result1 == 1 ); |
michael@0 | 206 | |
michael@0 | 207 | new TestCase( |
michael@0 | 208 | SECTION, |
michael@0 | 209 | "verify statements in for loop are evaluated", |
michael@0 | 210 | true, |
michael@0 | 211 | result2 == i ); |
michael@0 | 212 | |
michael@0 | 213 | new TestCase( |
michael@0 | 214 | SECTION, |
michael@0 | 215 | "verify break out of labeled for...in loop", |
michael@0 | 216 | true, |
michael@0 | 217 | result4 == 0 ); |
michael@0 | 218 | |
michael@0 | 219 | new TestCase( |
michael@0 | 220 | SECTION, |
michael@0 | 221 | "verify break out of labeled block", |
michael@0 | 222 | true, |
michael@0 | 223 | result3 == 0 ); |
michael@0 | 224 | } |
michael@0 | 225 | |
michael@0 | 226 | /** |
michael@0 | 227 | * Labeled continue from a labeled for...in loop |
michael@0 | 228 | */ |
michael@0 | 229 | function ForIn_7( object ) { |
michael@0 | 230 | var result1 = 0; |
michael@0 | 231 | var result2 = 0; |
michael@0 | 232 | var result3 = 0; |
michael@0 | 233 | var result4 = 0; |
michael@0 | 234 | var i = 0; |
michael@0 | 235 | var property = new Array(); |
michael@0 | 236 | |
michael@0 | 237 | bigredbird: |
michael@0 | 238 | for ( property[i++] in object ) { |
michael@0 | 239 | result2++; |
michael@0 | 240 | continue bigredbird; |
michael@0 | 241 | result4++; |
michael@0 | 242 | } |
michael@0 | 243 | |
michael@0 | 244 | new TestCase( |
michael@0 | 245 | SECTION, |
michael@0 | 246 | "verify statements in for loop are evaluated", |
michael@0 | 247 | true, |
michael@0 | 248 | result2 == i ); |
michael@0 | 249 | |
michael@0 | 250 | new TestCase( |
michael@0 | 251 | SECTION, |
michael@0 | 252 | "verify break out of labeled for...in loop", |
michael@0 | 253 | true, |
michael@0 | 254 | result4 == 0 ); |
michael@0 | 255 | |
michael@0 | 256 | new TestCase( |
michael@0 | 257 | SECTION, |
michael@0 | 258 | "verify break out of labeled block", |
michael@0 | 259 | true, |
michael@0 | 260 | result3 == 1 ); |
michael@0 | 261 | } |
michael@0 | 262 | |
michael@0 | 263 | |
michael@0 | 264 | /** |
michael@0 | 265 | * continue in a for...in loop |
michael@0 | 266 | * |
michael@0 | 267 | */ |
michael@0 | 268 | function ForIn_8( object ) { |
michael@0 | 269 | var checkBreak = "pass"; |
michael@0 | 270 | var properties = new Array(); |
michael@0 | 271 | var values = new Array(); |
michael@0 | 272 | |
michael@0 | 273 | for ( properties[properties.length] in object ) { |
michael@0 | 274 | values[values.length] = object[properties[properties.length-1]]; |
michael@0 | 275 | break; |
michael@0 | 276 | checkBreak = "fail"; |
michael@0 | 277 | } |
michael@0 | 278 | |
michael@0 | 279 | new TestCase( |
michael@0 | 280 | SECTION, |
michael@0 | 281 | "check break out of for...in", |
michael@0 | 282 | "pass", |
michael@0 | 283 | checkBreak ); |
michael@0 | 284 | |
michael@0 | 285 | new TestCase( |
michael@0 | 286 | SECTION, |
michael@0 | 287 | "properties.length", |
michael@0 | 288 | 1, |
michael@0 | 289 | properties.length ); |
michael@0 | 290 | |
michael@0 | 291 | new TestCase( |
michael@0 | 292 | SECTION, |
michael@0 | 293 | "object["+properties[0]+"]", |
michael@0 | 294 | values[0], |
michael@0 | 295 | object[properties[0]] ); |
michael@0 | 296 | } |
michael@0 | 297 |