js/src/tests/js1_5/Scope/regress-184107.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  *
     8  * Date:    09 December 2002
     9  * SUMMARY: with(...) { function f ...} should set f in the global scope
    10  * See http://bugzilla.mozilla.org/show_bug.cgi?id=184107
    11  *
    12  * In fact, any variable defined in a with-block should be created
    13  * in global scope, i.e. should be a property of the global object.
    14  *
    15  * The with-block syntax allows existing local variables to be SET,
    16  * but does not allow new local variables to be CREATED.
    17  *
    18  * See http://bugzilla.mozilla.org/show_bug.cgi?id=159849#c11
    19  */
    20 //-----------------------------------------------------------------------------
    21 var UBound = 0;
    22 var BUGNUMBER = 184107;
    23 var summary = 'with(...) { function f ...} should set f in the global scope';
    24 var status = '';
    25 var statusitems = [];
    26 var actual = '';
    27 var actualvalues = [];
    28 var expect= '';
    29 var expectedvalues = [];
    31 var obj = {y:10};
    32 with (obj)
    33 {
    34   // function statement
    35   function f()
    36   {
    37     return y;
    38   }
    40   // function expression
    41   g = function() {return y;}
    42 }
    44 status = inSection(1);
    45 actual = obj.f;
    46 expect = undefined;
    47 addThis();
    49 status = inSection(2);
    50 actual = f();
    51 expect = obj.y;
    52 addThis();
    54 status = inSection(3);
    55 actual = obj.g;
    56 expect = undefined;
    57 addThis();
    59 status = inSection(4);
    60 actual = g();
    61 expect = obj.y;
    62 addThis();
    66 //-----------------------------------------------------------------------------
    67 test();
    68 //-----------------------------------------------------------------------------
    72 function addThis()
    73 {
    74   statusitems[UBound] = status;
    75   actualvalues[UBound] = actual;
    76   expectedvalues[UBound] = expect;
    77   UBound++;
    78 }
    81 function test()
    82 {
    83   enterFunc('test');
    84   printBugNumber(BUGNUMBER);
    85   printStatus(summary);
    87   for (var i=0; i<UBound; i++)
    88   {
    89     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    90   }
    92   exitFunc ('test');
    93 }

mercurial