tor-browser

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

regress-348532.js (1393B)


      1 // |reftest| slow skip-if(Android)
      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 = 348532;
      9 var summary = 'Do not overflow int when constructing Error.stack';
     10 var actual = '';
     11 var expect = '';
     12 
     13 
     14 //-----------------------------------------------------------------------------
     15 test();
     16 //-----------------------------------------------------------------------------
     17 
     18 function test()
     19 {
     20  printBugNumber(BUGNUMBER);
     21  printStatus (summary);
     22 
     23  expectExitCode(0);
     24  expectExitCode(3);
     25  actual = 0;
     26 
     27  // construct string of 1<<23 characters
     28  var s = Array((1<<23)+1).join('x');
     29 
     30  var recursionDepth = 0;
     31  function err() {
     32    try {
     33        return err.apply(this, arguments);
     34    } catch (e) {
     35        if (!(e instanceof InternalError))
     36            throw e;
     37    }
     38    return new Error();
     39  }
     40 
     41  // The full stack trace in error would include 64*4 copies of s exceeding
     42  //  2^23 * 256 or 2^31 in length
     43  var error = err(s,s,s,s);
     44 
     45  print(error.stack.length);
     46 
     47  expect = true;
     48  actual = (error.stack.length > 0);
     49 
     50  reportCompare(expect, actual, summary);
     51 }