tor-browser

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

regress-404755.js (1220B)


      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 = 404755;
      9 var summary = 'Do not consume heap when deleting property';
     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  var n = 1 << 22;
     24  var o = {};
     25  do {
     26    o[0] = 0;
     27    delete o[0]; 
     28  } while (--n != 0);
     29 
     30  gc();
     31  var time = Date.now();
     32  gc();
     33  time = Date.now() - time;
     34 
     35  o = {};
     36  o[0] = 0;
     37  delete o[0]; 
     38  gc();
     39  var time2 = Date.now();
     40  gc();
     41  time2 = Date.now() - time2;
     42  print(time+" "+time2);
     43  if (time > 2 && time > time2 * 5)
     44    throw "A possible leak is observed";
     45 
     46  reportCompare(expect, actual, summary);
     47 }