js/src/tests/js1_5/Regress/regress-159334.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:    31 Oct 2002
     9  * SUMMARY: Testing script with at least 64K of different string literals
    10  * See http://bugzilla.mozilla.org/show_bug.cgi?id=159334
    11  *
    12  * Testing that script engine can handle scripts with at least 64K of different
    13  * string literals. The following will evaluate, via eval(), a script like this:
    14  *
    15  *     f('0')
    16  *     f('1')
    17  *     ...
    18  *     f('N - 1')
    19  *
    20  * where N is 0xFFFE
    21  *
    22  */
    23 //-----------------------------------------------------------------------------
    24 var UBound = 0;
    25 var BUGNUMBER = 159334;
    26 var summary = 'Testing script with at least 64K of different string literals';
    27 var status = '';
    28 var statusitems = [];
    29 var actual = '';
    30 var actualvalues = [];
    31 var expect= '';
    32 var expectedvalues = [];
    35 var N = 0xFFFE;
    37 // Create big string for eval recursively to avoid N*N behavior
    38 // on string concatenation
    39 var long_eval = buildEval_r(0, N);
    41 // Run it
    42 var test_sum = 0;
    43 function f(str) { test_sum += Number(str); }
    44 eval(long_eval);
    46 status = inSection(1);
    47 actual = (test_sum == N * (N - 1) / 2);
    48 expect = true;
    49 addThis();
    53 //-----------------------------------------------------------------------------
    54 test();
    55 //-----------------------------------------------------------------------------
    59 function buildEval_r(beginLine, endLine)
    60 {
    61   var count = endLine - beginLine;
    63   if (count == 0)
    64     return "";
    66   if (count == 1)
    67     return "f('" + beginLine + "')\n";
    69   var middle = beginLine + (count >>> 1);
    70   return buildEval_r(beginLine, middle) + buildEval_r(middle, endLine);
    71 }
    74 function addThis()
    75 {
    76   statusitems[UBound] = status;
    77   actualvalues[UBound] = actual;
    78   expectedvalues[UBound] = expect;
    79   UBound++;
    80 }
    83 function test()
    84 {
    85   enterFunc('test');
    86   printBugNumber(BUGNUMBER);
    87   printStatus(summary);
    89   for (var i=0; i<UBound; i++)
    90   {
    91     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    92   }
    94   exitFunc ('test');
    95 }

mercurial