js/src/tests/js1_5/Regress/regress-211590.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 var BUGNUMBER = 211590;
     8 var summary = 'Math.random should be random';
     9 var actual = '';
    10 var expect = 'between 47.5% and 52.5%';
    12 printBugNumber(BUGNUMBER);
    13 printStatus (summary);
    15 var r = Math.random;
    16 var c = Math.pow( 2, 53 );
    18 var n = 10000;
    19 var odd1 = 0;
    20 var odd2 = 0;
    22 for ( var i = 0; i < n; ++i )
    23 {
    24   var v= r() * c;
    25   if ( v & 1 )
    26     ++odd1;
    27   if ( v - c + c & 1 )
    28     ++odd2;
    29 }
    31 odd1 *= 100 / n;
    32 odd2 *= 100 / n;
    34 if (odd1 >= 47.5 && odd1 <= 52.5)
    35 {
    36   actual = expect;
    37 }
    38 else
    39 {
    40   actual = ' is ' + odd1.toFixed(3);
    41 }
    43 reportCompare(expect, actual, summary);
    45 if (odd2 >= 47.5 && odd2 <= 52.5)
    46 {
    47   actual = expect;
    48 }
    49 else
    50 {
    51   actual = ' is ' + odd2.toFixed(3);
    52 }
    54 reportCompare(expect, actual, summary);

mercurial