regress-204210.js (1810B)
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: 29 April 2003 9 * SUMMARY: eval() is not a constructor, but don't crash on |new eval();| 10 * 11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=204210 12 * 13 */ 14 //----------------------------------------------------------------------------- 15 var UBound = 0; 16 var BUGNUMBER = 204210; 17 var summary = "eval() is not a constructor, but don't crash on |new eval();|"; 18 var status = ''; 19 var statusitems = []; 20 var actual = ''; 21 var actualvalues = []; 22 var expect= ''; 23 var expectedvalues = []; 24 25 printBugNumber(BUGNUMBER); 26 printStatus(summary); 27 28 /* 29 * Just testing that we don't crash on any of these constructs - 30 */ 31 32 33 /* 34 * global scope - 35 */ 36 try 37 { 38 var x = new eval(); 39 new eval(); 40 } 41 catch(e) 42 { 43 } 44 45 46 /* 47 * function scope - 48 */ 49 f(); 50 function f() 51 { 52 try 53 { 54 var x = new eval(); 55 new eval(); 56 } 57 catch(e) 58 { 59 } 60 } 61 62 63 /* 64 * eval scope - 65 */ 66 var s = ''; 67 s += 'try'; 68 s += '{'; 69 s += ' var x = new eval();'; 70 s += ' new eval();'; 71 s += '}'; 72 s += 'catch(e)'; 73 s += '{'; 74 s += '}'; 75 eval(s); 76 77 78 /* 79 * some combinations of scope - 80 */ 81 s = ''; 82 s += 'function g()'; 83 s += '{'; 84 s += ' try'; 85 s += ' {'; 86 s += ' var x = new eval();'; 87 s += ' new eval();'; 88 s += ' }'; 89 s += ' catch(e)'; 90 s += ' {'; 91 s += ' }'; 92 s += '}'; 93 s += 'g();'; 94 eval(s); 95 96 97 function h() 98 { 99 var s = ''; 100 s += 'function f()'; 101 s += '{'; 102 s += ' try'; 103 s += ' {'; 104 s += ' var x = new eval();'; 105 s += ' new eval();'; 106 s += ' }'; 107 s += ' catch(e)'; 108 s += ' {'; 109 s += ' }'; 110 s += '}'; 111 s += 'f();'; 112 eval(s); 113 } 114 h(); 115 116 reportCompare('No Crash', 'No Crash', '');