js/src/tests/js1_5/Scope/regress-208496-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:    05 June 2003
     9  * SUMMARY: Testing |with (f)| inside the definition of |function f()|
    10  *
    11  * See http://bugzilla.mozilla.org/show_bug.cgi?id=208496
    12  *
    13  * In this test, we check that static function properties of
    14  * of |f| are read correctly from within the |with(f)| block.
    15  *
    16  */
    17 //-----------------------------------------------------------------------------
    18 var UBound = 0;
    19 var BUGNUMBER = 208496;
    20 var summary = 'Testing |with (f)| inside the definition of |function f()|';
    21 var STATIC_VALUE = 'read the static property';
    22 var status = '';
    23 var statusitems = [];
    24 var actual = '(TEST FAILURE)';
    25 var actualvalues = [];
    26 var expect= '';
    27 var expectedvalues = [];
    30 function f(par)
    31 {
    32   with(f)
    33   {
    34     actual = par;
    35   }
    37   return par;
    38 }
    39 f.par = STATIC_VALUE;
    42 status = inSection(1);
    43 f('abc'); // this sets |actual| inside |f|
    44 expect = STATIC_VALUE;
    45 addThis();
    47 // test the return: should be the dynamic value
    48 status = inSection(2);
    49 actual = f('abc');
    50 expect = 'abc';
    51 addThis();
    53 status = inSection(3);
    54 f(111 + 222); // sets |actual| inside |f|
    55 expect = STATIC_VALUE;
    56 addThis();
    58 // test the return: should be the dynamic value
    59 status = inSection(4);
    60 actual = f(111 + 222);
    61 expect = 333;
    62 addThis();
    65 /*
    66  * Add a level of indirection via |x|
    67  */
    68 function g(par)
    69 {
    70   with(g)
    71   {
    72     var x = par;
    73     actual = x;
    74   }
    76   return par;
    77 }
    78 g.par = STATIC_VALUE;
    81 status = inSection(5);
    82 g('abc'); // this sets |actual| inside |g|
    83 expect = STATIC_VALUE;
    84 addThis();
    86 // test the return: should be the dynamic value
    87 status = inSection(6);
    88 actual = g('abc');
    89 expect = 'abc';
    90 addThis();
    92 status = inSection(7);
    93 g(111 + 222); // sets |actual| inside |g|
    94 expect = STATIC_VALUE;
    95 addThis();
    97 // test the return: should be the dynamic value
    98 status = inSection(8);
    99 actual = g(111 + 222);
   100 expect = 333;
   101 addThis();
   105 //-----------------------------------------------------------------------------
   106 test();
   107 //-----------------------------------------------------------------------------
   111 function addThis()
   112 {
   113   statusitems[UBound] = status;
   114   actualvalues[UBound] = actual;
   115   expectedvalues[UBound] = expect;
   116   UBound++;
   117 }
   120 function test()
   121 {
   122   enterFunc('test');
   123   printBugNumber(BUGNUMBER);
   124   printStatus(summary);
   126   for (var i=0; i<UBound; i++)
   127   {
   128     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   129   }
   131   exitFunc ('test');
   132 }

mercurial