regress-192414.js (1987B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 /* 7 * 8 * Date: 08 February 2003 9 * SUMMARY: Parser recursion should check stack overflow 10 * 11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=192414 12 * 13 */ 14 //----------------------------------------------------------------------------- 15 var UBound = 0; 16 var BUGNUMBER = 192414; 17 var summary = 'Parser recursion should check stack overflow'; 18 var status = ''; 19 var statusitems = []; 20 var actual = ''; 21 var actualvalues = []; 22 var expect= ''; 23 var expectedvalues = []; 24 25 /* 26 * We will form an eval string to set the result-variable |actual|. 27 * To get a feel for this, suppose N were 3. Then the eval string is 28 * 'actual = (1&(1&(1&1)));' The expected value after eval() is 1. 29 */ 30 status = inSection(1); 31 var N = 10000; 32 var left = repeat_str('(1&', N); 33 var right = repeat_str(')', N); 34 var str = 'actual = '.concat(left, '1', right, ';'); 35 try 36 { 37 eval(str); 38 } 39 catch (e) 40 { 41 /* 42 * An exception during this eval is OK, as the runtime can throw one 43 * in response to too deep recursion. We haven't crashed; good! 44 */ 45 actual = 1; 46 } 47 expect = 1; 48 addThis(); 49 50 51 52 //----------------------------------------------------------------------------- 53 test(); 54 //----------------------------------------------------------------------------- 55 56 57 58 function repeat_str(str, repeat_count) 59 { 60 var arr = new Array(--repeat_count); 61 while (repeat_count != 0) 62 arr[--repeat_count] = str; 63 return str.concat.apply(str, arr); 64 } 65 66 67 function addThis() 68 { 69 statusitems[UBound] = status; 70 actualvalues[UBound] = actual; 71 expectedvalues[UBound] = expect; 72 UBound++; 73 } 74 75 76 function test() 77 { 78 printBugNumber(BUGNUMBER); 79 printStatus(summary); 80 81 for (var i=0; i<UBound; i++) 82 { 83 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 84 } 85 }