js/src/tests/js1_5/Scope/regress-77578-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  * Date: 2001-07-11
     8  *
     9  * SUMMARY: Testing eval scope inside a function.
    10  * See http://bugzilla.mozilla.org/show_bug.cgi?id=77578
    11  */
    12 //-----------------------------------------------------------------------------
    13 var UBound = 0;
    14 var BUGNUMBER = 77578;
    15 var summary = 'Testing eval scope inside a function';
    16 var cnEquals = '=';
    17 var status = '';
    18 var statusitems = [];
    19 var actual = '';
    20 var actualvalues = [];
    21 var expect= '';
    22 var expectedvalues = [];
    25 // various versions of JavaScript -
    26 var JS_VER = [100, 110, 120, 130, 140, 150];
    28 // Note contrast with local variables i,j,k defined below -
    29 var i = 999;
    30 var j = 999;
    31 var k = 999;
    34 //--------------------------------------------------
    35 test();
    36 //--------------------------------------------------
    39 function test()
    40 {
    41   enterFunc ('test');
    42   printBugNumber(BUGNUMBER);
    43   printStatus (summary);
    45   // Run tests A,B,C on each version of JS and store results
    46   for (var n=0; n!=JS_VER.length; n++)
    47   {
    48     testA(JS_VER[n]);
    49   }
    50   for (var n=0; n!=JS_VER.length; n++)
    51   {
    52     testB(JS_VER[n]);
    53   }
    54   for (var n=0; n!=JS_VER.length; n++)
    55   {
    56     testC(JS_VER[n]);
    57   }
    60   // Compare actual values to expected values -
    61   for (var i=0; i<UBound; i++)
    62   {
    63     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    64   }
    66   exitFunc ('test');
    67 }
    70 function testA(ver)
    71 {
    72   // Set the version of JS to test -
    73   if (typeof version == 'function')
    74   {
    75     version(ver);
    76   }
    78   // eval the test, so it compiles AFTER version() has executed -
    79   var sTestScript = "";
    81   // Define a local variable i
    82   sTestScript += "status = 'Section A of test; JS ' + ver/100;";
    83   sTestScript += "var i=1;";
    84   sTestScript += "actual = eval('i');";
    85   sTestScript += "expect = 1;";
    86   sTestScript += "captureThis('i');";
    88   eval(sTestScript);
    89 }
    92 function testB(ver)
    93 {
    94   // Set the version of JS to test -
    95   if (typeof version == 'function')
    96   {
    97     version(ver);
    98   }
   100   // eval the test, so it compiles AFTER version() has executed -
   101   var sTestScript = "";
   103   // Define a local for-loop iterator j
   104   sTestScript += "status = 'Section B of test; JS ' + ver/100;";
   105   sTestScript += "for(var j=1; j<2; j++)";
   106   sTestScript += "{";
   107   sTestScript += "  actual = eval('j');";
   108   sTestScript += "};";
   109   sTestScript += "expect = 1;";
   110   sTestScript += "captureThis('j');";
   112   eval(sTestScript);
   113 }
   116 function testC(ver)
   117 {
   118   // Set the version of JS to test -
   119   if (typeof version == 'function')
   120   {
   121     version(ver);
   122   }
   124   // eval the test, so it compiles AFTER version() has executed -
   125   var sTestScript = "";
   127   // Define a local variable k in a try-catch block -
   128   sTestScript += "status = 'Section C of test; JS ' + ver/100;";
   129   sTestScript += "try";
   130   sTestScript += "{";
   131   sTestScript += "  var k=1;";
   132   sTestScript += "  actual = eval('k');";
   133   sTestScript += "}";
   134   sTestScript += "catch(e)";
   135   sTestScript += "{";
   136   sTestScript += "};";
   137   sTestScript += "expect = 1;";
   138   sTestScript += "captureThis('k');";
   140   eval(sTestScript);
   141 }
   144 function captureThis(varName)
   145 {
   146   statusitems[UBound] = status;
   147   actualvalues[UBound] = varName + cnEquals + actual;
   148   expectedvalues[UBound] = varName + cnEquals + expect;
   149   UBound++;
   150 }

mercurial