js/src/jit-test/tests/arguments/defaults-scoping.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 var x = 'global';
     2 function f(a=x) {  // local variable x
     3     var x = 'local';
     4     return a;
     5 }
     6 assertEq(f(), undefined);
     8 function g(f=function () { return ++x; }) {  // closes on local variable x
     9     var x = 0;
    10     return f;
    11 }
    12 var gf = g();
    13 assertEq(gf(), 1);
    14 assertEq(gf(), 2);
    15 gf = g();
    16 assertEq(gf(), 1);
    18 function h(f=function (s) { return eval(s); }) {  // closes on local scope
    19     var x = 'hlocal';
    20     return f;
    21 }
    22 var hf = h();
    23 assertEq(hf('x'), 'hlocal');
    24 assertEq(hf('f'), hf);
    25 assertEq(hf('var x = 3; x'), 3);
    27 function j(expr, v=eval(expr)) {
    28     return v;
    29 }
    30 assertEq(j("expr"), "expr");
    31 assertEq(j("v"), undefined);
    32 assertEq(j("Array"), Array);
    33 assertEq(j("arguments").length, 1);

mercurial