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: * Date: 09 May 2001 michael@0: * michael@0: * SUMMARY: Regression test: we shouldn't crash on this code michael@0: * See http://bugzilla.mozilla.org/show_bug.cgi?id=72773 michael@0: * michael@0: * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property. michael@0: * michael@0: * Same as class-001.js - but testing user-defined types here, not michael@0: * native types. Therefore we expect the [[Class]] property to equal michael@0: * 'Object' in each case - michael@0: * michael@0: * The getJSClass() function we use is in a utility file, e.g. "shell.js" michael@0: */ michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 72773; michael@0: var summary = "Regression test: we shouldn't crash on this code"; michael@0: var status = ''; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: var sToEval = ''; michael@0: michael@0: /* michael@0: * This code should produce an error, but not a crash. michael@0: * 'TypeError: Function.prototype.toString called on incompatible object' michael@0: */ michael@0: sToEval += 'function Cow(name){this.name = name;}' michael@0: sToEval += 'function Calf(str){this.name = str;}' michael@0: sToEval += 'Calf.prototype = Cow;' michael@0: sToEval += 'new Calf().toString();' michael@0: michael@0: status = 'Trying to catch an expected error'; michael@0: try michael@0: { michael@0: eval(sToEval); michael@0: } michael@0: catch(e) michael@0: { michael@0: actual = getJSClass(e); michael@0: expect = 'Error'; michael@0: } michael@0: michael@0: michael@0: //---------------------------------------------------------------------------------------------- michael@0: test(); michael@0: //---------------------------------------------------------------------------------------------- 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: reportCompare(expect, actual, status); michael@0: michael@0: exitFunc ('test'); michael@0: }