js/src/tests/js1_7/extensions/regress-351070-02.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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 //-----------------------------------------------------------------------------
     7 var BUGNUMBER = 351070;
     8 var summary = 'decompilation of let declaration should not change scope';
     9 var actual = '';
    10 var expect = '';
    13 //-----------------------------------------------------------------------------
    14 test();
    15 //-----------------------------------------------------------------------------
    17 function test()
    18 {
    19   enterFunc ('test');
    20   printBugNumber(BUGNUMBER);
    21   printStatus (summary);
    23   try
    24   {
    25     var pfx  = "(function f() { var n = 2, a = 2; ",
    26       decl = " let a = 3;",
    27       end  = " return a; })";
    29     var table = [
    30       ["if (!!true)",       ""],
    31       ["if (!!true)",       " else foopy();"],
    32       ["if (!true); else",  ""],
    33       ["do ",               " while (false);"],
    34       ["while (--n)",       ""],
    35       ["for (--n;n;--n)",   ""],
    36       ["for (a in this)",   ""],
    37       ["with (this)",       ""],
    38       ];
    40     expect = 3;
    42     for (i = 0; i < table.length; i++) {
    43       var src = pfx + table[i][0] + decl + table[i][1] + end;
    44       print('src: ' + src);
    45       var fun = eval(src);
    46       var testval = fun();
    47       reportCompare(expect, testval, summary + ': ' + src);
    48       if (testval != expect) {
    49         break;
    50       }
    51       print('uneval: ' + uneval(fun));
    52       var declsrc = '(' +
    53         src.slice(1, -1).replace('function f', 'function f' + i) + ')';
    54       print('declsrc: ' + declsrc);
    55       this['f' + i] = eval(declsrc);
    56       print('f' + i + ': ' + this['f' + i]);
    57     }
    58   }
    59   catch(ex)
    60   {
    61     // See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
    62     summary = 'let declaration must be direct child of block or top-level implicit block';
    63     expect = 'SyntaxError';
    64     actual = ex.name;
    65     reportCompare(expect, actual, summary);
    66   }
    68   exitFunc ('test');
    69 }

mercurial