js/src/tests/js1_8_5/regress/regress-609617.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: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /*
michael@0 3 * Any copyright is dedicated to the Public Domain.
michael@0 4 * http://creativecommons.org/licenses/publicdomain/
michael@0 5 */
michael@0 6
michael@0 7 var actual;
michael@0 8 var expect = "pass";
michael@0 9
michael@0 10 var x = "fail";
michael@0 11 function f() {
michael@0 12 var x = "pass";
michael@0 13 delete(eval("actual = x"));
michael@0 14 }
michael@0 15 f();
michael@0 16 assertEq(actual, expect);
michael@0 17
michael@0 18 function g() { return 1 }
michael@0 19 function h() { function g() { throw 2; } eval('g()')++; }
michael@0 20
michael@0 21 try {
michael@0 22 h();
michael@0 23 assertEq(0, -1);
michael@0 24 } catch (e) {
michael@0 25 assertEq(e, 2);
michael@0 26 }
michael@0 27
michael@0 28 var lhs_prefix = ["", "++", "--", "", "", "[", "[y, " ];
michael@0 29 var lhs_suffix = [" = 'no'", "", "", "++", "--", ", y] = [3, 4]", "] = [5, 6]"];
michael@0 30
michael@0 31 for (var i = 0; i < lhs_prefix.length; i++) {
michael@0 32 try {
michael@0 33 eval(lhs_prefix[i] + "eval('x')" + lhs_suffix[i]);
michael@0 34 assertEq(i, -2);
michael@0 35 } catch (e) {
michael@0 36 /*
michael@0 37 * NB: JSOP_SETCALL throws only JSMSG_BAD_LEFTSIDE_OF_ASS, it does not
michael@0 38 * specialize for ++ and -- as the compiler's error reporting does. See
michael@0 39 * the next section's forked assertEq code.
michael@0 40 */
michael@0 41 assertEq(e.message, "invalid assignment left-hand side");
michael@0 42 }
michael@0 43 }
michael@0 44
michael@0 45 /* Destructuring desugars in the obvious way, so y must be 5 here. */
michael@0 46 assertEq(y, 5);
michael@0 47
michael@0 48 /* Now test for strict mode rejecting any SETCALL variant at compile time. */
michael@0 49 for (var i = 0; i < lhs_prefix.length; i++) {
michael@0 50 try {
michael@0 51 eval("(function () { 'use strict'; " + lhs_prefix[i] + "foo('x')" + lhs_suffix[i] + "; })");
michael@0 52 assertEq(i, -3);
michael@0 53 } catch (e) {
michael@0 54 if (/\+\+|\-\-/.test(lhs_prefix[i] || lhs_suffix[i]))
michael@0 55 assertEq(e.message, "invalid increment/decrement operand");
michael@0 56 else
michael@0 57 assertEq(e.message, "invalid assignment left-hand side");
michael@0 58 }
michael@0 59 }
michael@0 60
michael@0 61 /*
michael@0 62 * The useless delete is optimized away, but the SETCALL must not be. It's not
michael@0 63 * an early error, though.
michael@0 64 */
michael@0 65 var fooArg;
michael@0 66 function foo(arg) { fooArg = arg; }
michael@0 67 try {
michael@0 68 eval("delete (foo('x') = 42);");
michael@0 69 assertEq(0, -4);
michael@0 70 } catch (e) {
michael@0 71 assertEq(e.message, "invalid assignment left-hand side");
michael@0 72 }
michael@0 73 assertEq(fooArg, 'x');
michael@0 74
michael@0 75 /* Delete of a call expression is not an error at all, even in strict mode. */
michael@0 76 function g() {
michael@0 77 "use strict";
michael@0 78 assertEq(delete Object(), true);
michael@0 79 }
michael@0 80 g();
michael@0 81
michael@0 82 reportCompare(0, 0, "ok");

mercurial