js/src/tests/js1_5/Scope/regress-202678-002.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     self.outSideFunc = insideFunc;
    42   }
    45   function insideFunc()
    46   {
    47     actual = hidden;
    48   }
    49 }
    53 status = inSection(1);
    54 myFunc();  // this sets |actual|
    55 expect = 'aaa';
    56 addThis();
    58 status = inSection(2);
    59 outSideFunc();  // sets |actual|
    60 expect = 'bbb';
    61 addThis();
    63 status = inSection(3);
    64 myFunc();      // sets |actual|
    65 expect = 'aaa';
    66 addThis();
    68 status = inSection(4);
    69 outSideFunc();  // sets |actual|
    70 expect = 'ccc';
    71 addThis();
    76 //-----------------------------------------------------------------------------
    77 test();
    78 //-----------------------------------------------------------------------------
    82 function addThis()
    83 {
    84   statusitems[UBound] = status;
    85   actualvalues[UBound] = actual;
    86   expectedvalues[UBound] = expect;
    87   UBound++;
    88 }
    91 function test()
    92 {
    93   enterFunc('test');
    94   printBugNumber(BUGNUMBER);
    95   printStatus(summary);
    97   for (var i=0; i<UBound; i++)
    98   {
    99     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   100   }
   102   exitFunc ('test');
   103 }

mercurial