js/src/tests/ecma_6/Comprehensions/generator-semantics.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 // Interaction of eval with generator expressions.
     2 function a1() {
     3   var a = 10;
     4   var g = (for (y of [0]) eval('var a=42;'));
     5   g.next();
     6   return a;
     7 }
     8 assertEq(a1(), 10);
    10 function a2() {
    11   var a = 10;
    12   (for (y of [0]) eval('a=42')).next();
    13   return a;
    14 }
    15 assertEq(a2(), 42)
    17 // Arguments and this.
    18 function b1() {
    19   return [for (arg of (for (i of [0, 1, 2]) arguments[i])) arg];
    20 }
    21 assertDeepEq(b1('a', 'b', 'c'), ['a', 'b', 'c']);
    23 function b2() {
    24   return [for (x of (for (i of [0]) this)) x];
    25 }
    26 var b2o = { b2: b2 }
    27 assertDeepEq(b2o.b2(), [b2o])
    29 // Assignment to eval or arguments.
    30 function c1() {
    31   return [for (arg of (for (i of [0, 1, 2]) arguments = i)) arg];
    32 }
    33 assertDeepEq(c1(), [0, 1, 2]);
    35 function c2() {
    36   "use strict";
    37   return eval('[for (arg of (for (i of [0, 1, 2]) arguments = i)) arg]');
    38 }
    39 assertThrows(c2, SyntaxError);
    41 function c3() {
    42   return [for (arg of (for (i of [0, 1, 2]) eval = i)) arg];
    43 }
    44 assertDeepEq(c3(), [0, 1, 2]);
    46 function c4() {
    47   "use strict";
    48   return eval('[for (arg of (for (i of [0, 1, 2]) eval = i)) arg]');
    49 }
    50 assertThrows(c4, SyntaxError);
    52 reportCompare(null, null, "test");

mercurial