michael@0: // |reftest| skip-if(Android) michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 348532; michael@0: var summary = 'Do not overflow int when constructing Error.stack'; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: test(); michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: function test() michael@0: { michael@0: enterFunc ('test'); michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: expectExitCode(0); michael@0: expectExitCode(3); michael@0: actual = 0; michael@0: michael@0: // construct string of 1<<23 characters michael@0: var s = Array((1<<23)+1).join('x'); michael@0: michael@0: var recursionDepth = 0; michael@0: function err() { michael@0: try { michael@0: return err.apply(this, arguments); michael@0: } catch (e) { michael@0: if (!(e instanceof InternalError)) michael@0: throw e; michael@0: } michael@0: return new Error(); michael@0: } michael@0: michael@0: // The full stack trace in error would include 64*4 copies of s exceeding michael@0: // 2^23 * 256 or 2^31 in length michael@0: var error = err(s,s,s,s); michael@0: michael@0: print(error.stack.length); michael@0: michael@0: expect = true; michael@0: actual = (error.stack.length > 0); michael@0: michael@0: reportCompare(expect, actual, summary); michael@0: michael@0: exitFunc ('test'); michael@0: }