js/src/tests/ecma_5/strict/rebind-eval-should-fail-in-strict-mode.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.

     1 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  */
     6 var BadSyntaxStrings = [
     7     "function foo1() { \"use strict\"; try {} catch (eval) {} }",
     8     "function foo2() { \"use strict\"; let eval = 9; foo(); }",
     9     "function foo3() { \"use strict\"; for (let eval = 3;;) { foo(); }}",
    10     "function foo4() { \"use strict\"; for (let eval in {a:1}) { foo(); }}",
    11     "function foo5() { \"use strict\"; for (let eval of [1, 2, 3]) { foo(); }}",
    12     "function foo6() { \"use strict\"; var eval = 12; }",
    13     "function foo7() { \"use strict\"; for (var eval = 3;;) { foo(); }}",
    14     "function foo8() { \"use strict\"; for (var eval in {a:1}) { foo(); }}",
    15     "function foo9() { \"use strict\"; for (var eval of [1, 2, 3]) { foo(); }}",
    16     "function foo10() { \"use strict\"; const eval = 12; }",
    17     "function foo11() { \"use strict\"; for (const eval = 3;;) { foo(); }}",
    18     "function foo12() { \"use strict\"; return [eval for (eval of [1, 2, 3])]; }",
    19     "function foo13() { \"use strict\"; return [eval for (eval in {a:3})]; }",
    20     "function foo14() { \"use strict\"; return (eval for (eval of [1, 2, 3])); }",
    21     "function foo15() { \"use strict\"; return (eval for (eval in {a:3})); }"
    22 ];
    24 function testString(s, i) {
    25     var gotSyntaxError = -1;
    26     try {
    27         eval(s);
    28     } catch(err) {
    29         if (err instanceof SyntaxError)
    30             gotSyntaxError = i;
    31     }
    33     assertEq(gotSyntaxError, i);
    34 }
    36 for (var i = 0; i < BadSyntaxStrings.length; i++)
    37     testString(BadSyntaxStrings[i], i);
    39 reportCompare(true, true);

mercurial