js/src/tests/js1_5/Scope/regress-202678-001.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:    19 April 2003
     9  * SUMMARY: Testing nested function scope capture
    10  *
    11  * See http://bugzilla.mozilla.org/show_bug.cgi?id=202678
    12  *
    13  */
    14 //-----------------------------------------------------------------------------
    15 var UBound = 0;
    16 var BUGNUMBER = 202678;
    17 var summary = 'Testing nested function scope capture';
    18 var status = '';
    19 var statusitems = [];
    20 var actual = '';
    21 var actualvalues = [];
    22 var expect= '';
    23 var expectedvalues = [];
    24 var self = this;
    27 function myFunc()
    28 {
    29   var hidden = 'aaa';
    30   insideFunc();
    32   if (!self.runOnce)
    33   {
    34     var hidden = 'bbb';
    35     self.outSideFunc = insideFunc;
    36     self.runOnce = true;
    37   }
    38   else
    39   {
    40     var hidden = 'ccc';
    41   }
    44   function insideFunc()
    45   {
    46     actual = hidden;
    47   }
    48 }
    52 status = inSection(1);
    53 myFunc();  // this sets |actual|
    54 expect = 'aaa';
    55 addThis();
    57 status = inSection(2);
    58 outSideFunc();  // sets |actual|
    59 expect = 'bbb';
    60 addThis();
    62 status = inSection(3);
    63 myFunc();      // sets |actual|
    64 expect = 'aaa';
    65 addThis();
    67 status = inSection(4);
    68 outSideFunc();  // sets |actual|
    69 expect = 'bbb'; // NOT 'ccc'
    70 addThis();
    75 //-----------------------------------------------------------------------------
    76 test();
    77 //-----------------------------------------------------------------------------
    81 function addThis()
    82 {
    83   statusitems[UBound] = status;
    84   actualvalues[UBound] = actual;
    85   expectedvalues[UBound] = expect;
    86   UBound++;
    87 }
    90 function test()
    91 {
    92   enterFunc('test');
    93   printBugNumber(BUGNUMBER);
    94   printStatus(summary);
    96   for (var i=0; i<UBound; i++)
    97   {
    98     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    99   }
   101   exitFunc ('test');
   102 }

mercurial