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 = 290575; michael@0: var summary = 'Do not crash calling function with more than 32768 arguments'; michael@0: var actual = 'No Crash'; michael@0: var expect = 'No Crash'; michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: function crashMe(n) { michael@0: var nasty, fn; michael@0: michael@0: nasty = []; michael@0: while (n--) michael@0: nasty.push("a"+n); // Function arguments michael@0: nasty.push("void 0"); // Function body michael@0: fn = Function.apply(null, nasty); michael@0: fn.toString(); michael@0: } michael@0: michael@0: printStatus('crashMe(0x8001)'); michael@0: michael@0: crashMe(0x8001); michael@0: michael@0: reportCompare(expect, actual, summary); michael@0: michael@0: function crashMe2(n) { michael@0: var nasty = [], fn michael@0: michael@0: while (n--) nasty[n] = "a"+n michael@0: fn = Function(nasty.join(), "void 0") michael@0: fn.toString() michael@0: } michael@0: michael@0: printStatus('crashMe2(0x10000)'); michael@0: michael@0: summary = 'Syntax Error Function to string when more than 65536 arguments'; michael@0: expect = 'Error'; michael@0: try michael@0: { michael@0: crashMe2(0x10000); michael@0: actual = 'No Error'; michael@0: reportCompare(expect, actual, summary); michael@0: } michael@0: catch(e) michael@0: { michael@0: actual = 'Error'; michael@0: reportCompare(expect, actual, summary); michael@0: expect = 'SyntaxError'; michael@0: actual = e.name; michael@0: reportCompare(expect, actual, summary); michael@0: } michael@0: