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: * michael@0: * Date: 29 April 2003 michael@0: * SUMMARY: eval() is not a constructor, but don't crash on |new eval();| michael@0: * michael@0: * See http://bugzilla.mozilla.org/show_bug.cgi?id=204210 michael@0: * michael@0: */ michael@0: //----------------------------------------------------------------------------- michael@0: var UBound = 0; michael@0: var BUGNUMBER = 204210; michael@0: var summary = "eval() is not a constructor, but don't crash on |new eval();|"; michael@0: var status = ''; michael@0: var statusitems = []; michael@0: var actual = ''; michael@0: var actualvalues = []; michael@0: var expect= ''; michael@0: var expectedvalues = []; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus(summary); michael@0: michael@0: /* michael@0: * Just testing that we don't crash on any of these constructs - michael@0: */ michael@0: michael@0: michael@0: /* michael@0: * global scope - michael@0: */ michael@0: try michael@0: { michael@0: var x = new eval(); michael@0: new eval(); michael@0: } michael@0: catch(e) michael@0: { michael@0: } michael@0: michael@0: michael@0: /* michael@0: * function scope - michael@0: */ michael@0: f(); michael@0: function f() michael@0: { michael@0: try michael@0: { michael@0: var x = new eval(); michael@0: new eval(); michael@0: } michael@0: catch(e) michael@0: { michael@0: } michael@0: } michael@0: michael@0: michael@0: /* michael@0: * eval scope - michael@0: */ michael@0: var s = ''; michael@0: s += 'try'; michael@0: s += '{'; michael@0: s += ' var x = new eval();'; michael@0: s += ' new eval();'; michael@0: s += '}'; michael@0: s += 'catch(e)'; michael@0: s += '{'; michael@0: s += '}'; michael@0: eval(s); michael@0: michael@0: michael@0: /* michael@0: * some combinations of scope - michael@0: */ michael@0: s = ''; michael@0: s += 'function g()'; michael@0: s += '{'; michael@0: s += ' try'; michael@0: s += ' {'; michael@0: s += ' var x = new eval();'; michael@0: s += ' new eval();'; michael@0: s += ' }'; michael@0: s += ' catch(e)'; michael@0: s += ' {'; michael@0: s += ' }'; michael@0: s += '}'; michael@0: s += 'g();'; michael@0: eval(s); michael@0: michael@0: michael@0: function h() michael@0: { michael@0: var s = ''; michael@0: s += 'function f()'; michael@0: s += '{'; michael@0: s += ' try'; michael@0: s += ' {'; michael@0: s += ' var x = new eval();'; michael@0: s += ' new eval();'; michael@0: s += ' }'; michael@0: s += ' catch(e)'; michael@0: s += ' {'; michael@0: s += ' }'; michael@0: s += '}'; michael@0: s += 'f();'; michael@0: eval(s); michael@0: } michael@0: h(); michael@0: michael@0: reportCompare('No Crash', 'No Crash', '');