tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

regress-383269-01.js (1539B)


      1 // |reftest| random -- unreliable - based on GC timing
      2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 //-----------------------------------------------------------------------------
      8 var BUGNUMBER = 383269;
      9 var summary = 'Leak related to arguments object';
     10 var actual = 'No Leak';
     11 var expect = 'No Leak';
     12 
     13 
     14 //-----------------------------------------------------------------------------
     15 test();
     16 //-----------------------------------------------------------------------------
     17 
     18 function test()
     19 {
     20  printBugNumber(BUGNUMBER);
     21  printStatus (summary);
     22 
     23  function generate_big_object_graph()
     24  {
     25    var root = {};
     26    f(root, 17);
     27    return root;
     28    function f(parent, depth) {
     29      if (depth == 0)
     30        return;
     31      --depth;
     32      f(parent.a = {}, depth);
     33      f(parent.b = {}, depth);
     34    }
     35  }
     36 
     37  function outer() {  var x = arguments; return function inner() { return x }; }
     38 
     39  function timed_gc()
     40  {
     41    var t1 = Date.now();
     42    gc();
     43    return Date.now() - t1;
     44  }
     45 
     46  outer(1);
     47  gc();
     48  var base_time = timed_gc();
     49 
     50  var f = outer(generate_big_object_graph());
     51  f = null;
     52  gc();
     53  var time = timed_gc();
     54 
     55  if (time > (base_time + 1) * 3)
     56    actual = "generate_big_object_graph() leaked, base_gc_time="+base_time+", last_gc_time="+time;
     57 
     58  reportCompare(expect, actual, summary);
     59 }