js/src/tests/js1_5/GC/regress-311497.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 = 311497;
     8 var summary = 'Root pivots in js_HeapSort';
     9 var actual = 'No Crash';
    10 var expect = 'No Crash';
    12 printBugNumber(BUGNUMBER);
    13 printStatus (summary);
    16 function force_gc()
    17 {
    18   if (this.gc) gc();
    19   for (var i = 0; i != 30000; ++i) {
    20     var tmp = Math.sin(i);
    21     tmp = null;
    22   }
    23 }
    25 var array = new Array(10);
    26 for (var i = 0; i != array.length; ++i) {
    27   array[i] = String.fromCharCode(i, i, i);
    28 }
    30 function cmp(a, b)
    31 {
    32   for (var i = 0; i != array.length; ++i) {
    33     array[i] = null;
    34   }
    35   force_gc();
    36   return 0;
    37 }
    39 array.sort(cmp);
    41 // Verify that array contains either null or original strings
    43 var null_count = 0;
    44 var original_string_count = 0;
    45 for (var i = 0; i != array.length; ++i) {
    46   var elem = array[i];
    47   if (elem === null) {
    48     ++null_count;
    49   } else if (typeof elem == "string" && elem.length == 3) {
    50     var code = elem.charCodeAt(0);
    51     if (0 <= code && code < array.length) {
    52       if (code === elem.charCodeAt(1) && code == elem.charCodeAt(2))
    53 	++original_string_count;
    54     }
    55   }
    56 }
    58 var expect = array.length;
    59 var actual = null_count + original_string_count;
    61 reportCompare(expect, actual, summary);

mercurial