js/src/tests/ecma_5/strict/13.1.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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
michael@0 3 /*
michael@0 4 * Any copyright is dedicated to the Public Domain.
michael@0 5 * http://creativecommons.org/licenses/publicdomain/
michael@0 6 */
michael@0 7
michael@0 8 /*
michael@0 9 * In strict mode, it is a syntax error for an identifier to appear
michael@0 10 * more than once in a function's argument list.
michael@0 11 */
michael@0 12
michael@0 13 /*
michael@0 14 * The parameters of ordinary function definitions should not contain
michael@0 15 * duplicate identifiers.
michael@0 16 */
michael@0 17 assertEq(testLenientAndStrict('function f(x,y) {}',
michael@0 18 parsesSuccessfully,
michael@0 19 parsesSuccessfully),
michael@0 20 true);
michael@0 21 assertEq(testLenientAndStrict('function f(x,x) {}',
michael@0 22 parsesSuccessfully,
michael@0 23 parseRaisesException(SyntaxError)),
michael@0 24 true);
michael@0 25 assertEq(testLenientAndStrict('function f(x,y,z,y) {}',
michael@0 26 parsesSuccessfully,
michael@0 27 parseRaisesException(SyntaxError)),
michael@0 28 true);
michael@0 29
michael@0 30 /* Exercise the hashed local name map case. */
michael@0 31 assertEq(testLenientAndStrict('function f(a,b,c,d,e,f,g,h,d) {}',
michael@0 32 parsesSuccessfully,
michael@0 33 parseRaisesException(SyntaxError)),
michael@0 34 true);
michael@0 35
michael@0 36 /*
michael@0 37 * SpiderMonkey has always treated duplicates in destructuring
michael@0 38 * patterns as an error. Strict mode should not affect this.
michael@0 39 */
michael@0 40 assertEq(testLenientAndStrict('function f([x,y]) {}',
michael@0 41 parsesSuccessfully,
michael@0 42 parsesSuccessfully),
michael@0 43 true);
michael@0 44 assertEq(testLenientAndStrict('function f([x,x]){}',
michael@0 45 parseRaisesException(SyntaxError),
michael@0 46 parseRaisesException(SyntaxError)),
michael@0 47 true);
michael@0 48 assertEq(testLenientAndStrict('function f(x,[x]){}',
michael@0 49 parseRaisesException(SyntaxError),
michael@0 50 parseRaisesException(SyntaxError)),
michael@0 51 true);
michael@0 52
michael@0 53 /*
michael@0 54 * Strict rules apply to the parameters if the function's body is
michael@0 55 * strict.
michael@0 56 */
michael@0 57 assertEq(testLenientAndStrict('function f(x,x) { "use strict" };',
michael@0 58 parseRaisesException(SyntaxError),
michael@0 59 parseRaisesException(SyntaxError)),
michael@0 60 true);
michael@0 61
michael@0 62 /*
michael@0 63 * Calls to the function constructor should not be affected by the
michael@0 64 * strictness of the calling code, but should be affected by the
michael@0 65 * strictness of the function body.
michael@0 66 */
michael@0 67 assertEq(testLenientAndStrict('Function("x","x","")',
michael@0 68 completesNormally,
michael@0 69 completesNormally),
michael@0 70 true);
michael@0 71 assertEq(testLenientAndStrict('Function("x","y","")',
michael@0 72 completesNormally,
michael@0 73 completesNormally),
michael@0 74 true);
michael@0 75 assertEq(testLenientAndStrict('Function("x","x","\'use strict\'")',
michael@0 76 raisesException(SyntaxError),
michael@0 77 raisesException(SyntaxError)),
michael@0 78 true);
michael@0 79 assertEq(testLenientAndStrict('Function("x","y","\'use strict\'")',
michael@0 80 completesNormally,
michael@0 81 completesNormally),
michael@0 82 true);
michael@0 83
michael@0 84
michael@0 85 /*
michael@0 86 * The parameter lists of function expressions should not contain
michael@0 87 * duplicate identifiers.
michael@0 88 */
michael@0 89 assertEq(testLenientAndStrict('(function (x,x) 2)',
michael@0 90 parsesSuccessfully,
michael@0 91 parseRaisesException(SyntaxError)),
michael@0 92 true);
michael@0 93 assertEq(testLenientAndStrict('(function (x,y) 2)',
michael@0 94 parsesSuccessfully,
michael@0 95 parsesSuccessfully),
michael@0 96 true);
michael@0 97
michael@0 98 /*
michael@0 99 * All permutations of:
michael@0 100 * - For the two magic identifiers 'arguments' or 'eval'
michael@0 101 * - For function definitions, function expressions, expression closures,
michael@0 102 * and getter and setter property definitions,
michael@0 103 * - For forms that inherit their context's strictness, and forms that
michael@0 104 * include their own strictness directives,
michael@0 105 * - For ordinary parameters, array destructuring parameters, and
michael@0 106 * object destructuring parameters,
michael@0 107 * - the magic identifiers may be used to name such parameters
michael@0 108 * in lenient code, but not in strict code
michael@0 109 * - the magic identifiers may be used as function names in lenient code,
michael@0 110 * but not in strict code
michael@0 111 */
michael@0 112 assertEq(testLenientAndStrict('function f(eval){}',
michael@0 113 parsesSuccessfully,
michael@0 114 parseRaisesException(SyntaxError)),
michael@0 115 true);
michael@0 116 assertEq(testLenientAndStrict('function f([eval]){}',
michael@0 117 parsesSuccessfully,
michael@0 118 parseRaisesException(SyntaxError)),
michael@0 119 true);
michael@0 120 assertEq(testLenientAndStrict('function f({x:eval}){}',
michael@0 121 parsesSuccessfully,
michael@0 122 parseRaisesException(SyntaxError)),
michael@0 123 true);
michael@0 124 assertEq(testLenientAndStrict('function eval(){}',
michael@0 125 parsesSuccessfully,
michael@0 126 parseRaisesException(SyntaxError)),
michael@0 127 true);
michael@0 128 assertEq(testLenientAndStrict('function f(eval){"use strict";}',
michael@0 129 parseRaisesException(SyntaxError),
michael@0 130 parseRaisesException(SyntaxError)),
michael@0 131 true);
michael@0 132 assertEq(testLenientAndStrict('function f([eval]){"use strict";}',
michael@0 133 parseRaisesException(SyntaxError),
michael@0 134 parseRaisesException(SyntaxError)),
michael@0 135 true);
michael@0 136 assertEq(testLenientAndStrict('function f({x:eval}){"use strict";}',
michael@0 137 parseRaisesException(SyntaxError),
michael@0 138 parseRaisesException(SyntaxError)),
michael@0 139 true);
michael@0 140 assertEq(testLenientAndStrict('function eval(){"use strict";}',
michael@0 141 parseRaisesException(SyntaxError),
michael@0 142 parseRaisesException(SyntaxError)),
michael@0 143 true);
michael@0 144 assertEq(testLenientAndStrict('(function f(eval){})',
michael@0 145 parsesSuccessfully,
michael@0 146 parseRaisesException(SyntaxError)),
michael@0 147 true);
michael@0 148 assertEq(testLenientAndStrict('(function f([eval]){})',
michael@0 149 parsesSuccessfully,
michael@0 150 parseRaisesException(SyntaxError)),
michael@0 151 true);
michael@0 152 assertEq(testLenientAndStrict('(function f({x:eval}){})',
michael@0 153 parsesSuccessfully,
michael@0 154 parseRaisesException(SyntaxError)),
michael@0 155 true);
michael@0 156 assertEq(testLenientAndStrict('(function eval(){})',
michael@0 157 parsesSuccessfully,
michael@0 158 parseRaisesException(SyntaxError)),
michael@0 159 true);
michael@0 160 assertEq(testLenientAndStrict('(function f(eval){"use strict";})',
michael@0 161 parseRaisesException(SyntaxError),
michael@0 162 parseRaisesException(SyntaxError)),
michael@0 163 true);
michael@0 164 assertEq(testLenientAndStrict('(function f([eval]){"use strict";})',
michael@0 165 parseRaisesException(SyntaxError),
michael@0 166 parseRaisesException(SyntaxError)),
michael@0 167 true);
michael@0 168 assertEq(testLenientAndStrict('(function f({x:eval}){"use strict";})',
michael@0 169 parseRaisesException(SyntaxError),
michael@0 170 parseRaisesException(SyntaxError)),
michael@0 171 true);
michael@0 172 assertEq(testLenientAndStrict('(function eval(){"use strict";})',
michael@0 173 parseRaisesException(SyntaxError),
michael@0 174 parseRaisesException(SyntaxError)),
michael@0 175 true);
michael@0 176 assertEq(testLenientAndStrict('(function f(eval) 2)',
michael@0 177 parsesSuccessfully,
michael@0 178 parseRaisesException(SyntaxError)),
michael@0 179 true);
michael@0 180 assertEq(testLenientAndStrict('(function f([eval]) 2)',
michael@0 181 parsesSuccessfully,
michael@0 182 parseRaisesException(SyntaxError)),
michael@0 183 true);
michael@0 184 assertEq(testLenientAndStrict('(function f({x:eval}) 2)',
michael@0 185 parsesSuccessfully,
michael@0 186 parseRaisesException(SyntaxError)),
michael@0 187 true);
michael@0 188 assertEq(testLenientAndStrict('(function eval() 2)',
michael@0 189 parsesSuccessfully,
michael@0 190 parseRaisesException(SyntaxError)),
michael@0 191 true);
michael@0 192 assertEq(testLenientAndStrict('({set x(eval){}})',
michael@0 193 parsesSuccessfully,
michael@0 194 parseRaisesException(SyntaxError)),
michael@0 195 true);
michael@0 196 assertEq(testLenientAndStrict('({set x([eval]){}})',
michael@0 197 parsesSuccessfully,
michael@0 198 parseRaisesException(SyntaxError)),
michael@0 199 true);
michael@0 200 assertEq(testLenientAndStrict('({set x({x:eval}){}})',
michael@0 201 parsesSuccessfully,
michael@0 202 parseRaisesException(SyntaxError)),
michael@0 203 true);
michael@0 204 assertEq(testLenientAndStrict('({set x(eval){"use strict";}})',
michael@0 205 parseRaisesException(SyntaxError),
michael@0 206 parseRaisesException(SyntaxError)),
michael@0 207 true);
michael@0 208 assertEq(testLenientAndStrict('({set x([eval]){"use strict";}})',
michael@0 209 parseRaisesException(SyntaxError),
michael@0 210 parseRaisesException(SyntaxError)),
michael@0 211 true);
michael@0 212 assertEq(testLenientAndStrict('({set x({x:eval}){"use strict";}})',
michael@0 213 parseRaisesException(SyntaxError),
michael@0 214 parseRaisesException(SyntaxError)),
michael@0 215 true);
michael@0 216 assertEq(testLenientAndStrict('function f(arguments){}',
michael@0 217 parsesSuccessfully,
michael@0 218 parseRaisesException(SyntaxError)),
michael@0 219 true);
michael@0 220 assertEq(testLenientAndStrict('function f([arguments]){}',
michael@0 221 parsesSuccessfully,
michael@0 222 parseRaisesException(SyntaxError)),
michael@0 223 true);
michael@0 224 assertEq(testLenientAndStrict('function f({x:arguments}){}',
michael@0 225 parsesSuccessfully,
michael@0 226 parseRaisesException(SyntaxError)),
michael@0 227 true);
michael@0 228 assertEq(testLenientAndStrict('function arguments(){}',
michael@0 229 parsesSuccessfully,
michael@0 230 parseRaisesException(SyntaxError)),
michael@0 231 true);
michael@0 232 assertEq(testLenientAndStrict('function f(arguments){"use strict";}',
michael@0 233 parseRaisesException(SyntaxError),
michael@0 234 parseRaisesException(SyntaxError)),
michael@0 235 true);
michael@0 236 assertEq(testLenientAndStrict('function f([arguments]){"use strict";}',
michael@0 237 parseRaisesException(SyntaxError),
michael@0 238 parseRaisesException(SyntaxError)),
michael@0 239 true);
michael@0 240 assertEq(testLenientAndStrict('function f({x:arguments}){"use strict";}',
michael@0 241 parseRaisesException(SyntaxError),
michael@0 242 parseRaisesException(SyntaxError)),
michael@0 243 true);
michael@0 244 assertEq(testLenientAndStrict('function arguments(){"use strict";}',
michael@0 245 parseRaisesException(SyntaxError),
michael@0 246 parseRaisesException(SyntaxError)),
michael@0 247 true);
michael@0 248 assertEq(testLenientAndStrict('(function f(arguments){})',
michael@0 249 parsesSuccessfully,
michael@0 250 parseRaisesException(SyntaxError)),
michael@0 251 true);
michael@0 252 assertEq(testLenientAndStrict('(function f([arguments]){})',
michael@0 253 parsesSuccessfully,
michael@0 254 parseRaisesException(SyntaxError)),
michael@0 255 true);
michael@0 256 assertEq(testLenientAndStrict('(function f({x:arguments}){})',
michael@0 257 parsesSuccessfully,
michael@0 258 parseRaisesException(SyntaxError)),
michael@0 259 true);
michael@0 260 assertEq(testLenientAndStrict('(function arguments(){})',
michael@0 261 parsesSuccessfully,
michael@0 262 parseRaisesException(SyntaxError)),
michael@0 263 true);
michael@0 264 assertEq(testLenientAndStrict('(function f(arguments){"use strict";})',
michael@0 265 parseRaisesException(SyntaxError),
michael@0 266 parseRaisesException(SyntaxError)),
michael@0 267 true);
michael@0 268 assertEq(testLenientAndStrict('(function f([arguments]){"use strict";})',
michael@0 269 parseRaisesException(SyntaxError),
michael@0 270 parseRaisesException(SyntaxError)),
michael@0 271 true);
michael@0 272 assertEq(testLenientAndStrict('(function f({x:arguments}){"use strict";})',
michael@0 273 parseRaisesException(SyntaxError),
michael@0 274 parseRaisesException(SyntaxError)),
michael@0 275 true);
michael@0 276 assertEq(testLenientAndStrict('(function arguments(){"use strict";})',
michael@0 277 parseRaisesException(SyntaxError),
michael@0 278 parseRaisesException(SyntaxError)),
michael@0 279 true);
michael@0 280 assertEq(testLenientAndStrict('(function f(arguments) 2)',
michael@0 281 parsesSuccessfully,
michael@0 282 parseRaisesException(SyntaxError)),
michael@0 283 true);
michael@0 284 assertEq(testLenientAndStrict('(function f([arguments]) 2)',
michael@0 285 parsesSuccessfully,
michael@0 286 parseRaisesException(SyntaxError)),
michael@0 287 true);
michael@0 288 assertEq(testLenientAndStrict('(function f({x:arguments}) 2)',
michael@0 289 parsesSuccessfully,
michael@0 290 parseRaisesException(SyntaxError)),
michael@0 291 true);
michael@0 292 assertEq(testLenientAndStrict('(function arguments() 2)',
michael@0 293 parsesSuccessfully,
michael@0 294 parseRaisesException(SyntaxError)),
michael@0 295 true);
michael@0 296 assertEq(testLenientAndStrict('({set x(arguments){}})',
michael@0 297 parsesSuccessfully,
michael@0 298 parseRaisesException(SyntaxError)),
michael@0 299 true);
michael@0 300 assertEq(testLenientAndStrict('({set x([arguments]){}})',
michael@0 301 parsesSuccessfully,
michael@0 302 parseRaisesException(SyntaxError)),
michael@0 303 true);
michael@0 304 assertEq(testLenientAndStrict('({set x({x:arguments}){}})',
michael@0 305 parsesSuccessfully,
michael@0 306 parseRaisesException(SyntaxError)),
michael@0 307 true);
michael@0 308 assertEq(testLenientAndStrict('({set x(arguments){"use strict";}})',
michael@0 309 parseRaisesException(SyntaxError),
michael@0 310 parseRaisesException(SyntaxError)),
michael@0 311 true);
michael@0 312 assertEq(testLenientAndStrict('({set x([arguments]){"use strict";}})',
michael@0 313 parseRaisesException(SyntaxError),
michael@0 314 parseRaisesException(SyntaxError)),
michael@0 315 true);
michael@0 316 assertEq(testLenientAndStrict('({set x({x:arguments}){"use strict";}})',
michael@0 317 parseRaisesException(SyntaxError),
michael@0 318 parseRaisesException(SyntaxError)),
michael@0 319 true);
michael@0 320
michael@0 321 /*
michael@0 322 * Functions produced using the Function constructor may not use
michael@0 323 * 'eval' or 'arguments' as a parameter name if their body is strict
michael@0 324 * mode code. The strictness of the calling code does not affect the
michael@0 325 * constraints applied to the parameters.
michael@0 326 */
michael@0 327 assertEq(testLenientAndStrict('Function("eval","")',
michael@0 328 completesNormally,
michael@0 329 completesNormally),
michael@0 330 true);
michael@0 331 assertEq(testLenientAndStrict('Function("eval","\'use strict\';")',
michael@0 332 raisesException(SyntaxError),
michael@0 333 raisesException(SyntaxError)),
michael@0 334 true);
michael@0 335 assertEq(testLenientAndStrict('Function("arguments","")',
michael@0 336 completesNormally,
michael@0 337 completesNormally),
michael@0 338 true);
michael@0 339 assertEq(testLenientAndStrict('Function("arguments","\'use strict\';")',
michael@0 340 raisesException(SyntaxError),
michael@0 341 raisesException(SyntaxError)),
michael@0 342 true);
michael@0 343
michael@0 344
michael@0 345 reportCompare(true, true);

mercurial