| 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 | * Date: 09 May 2001 |
| 8 | * |
| 9 | * SUMMARY: Regression test: we shouldn't crash on this code |
| 10 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=72773 |
| 11 | * |
| 12 | * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property. |
| 13 | * |
| 14 | * Same as class-001.js - but testing user-defined types here, not |
| 15 | * native types. Therefore we expect the [[Class]] property to equal |
| 16 | * 'Object' in each case - |
| 17 | * |
| 18 | * The getJSClass() function we use is in a utility file, e.g. "shell.js" |
| 19 | */ |
| 20 | //----------------------------------------------------------------------------- |
| 21 | var gTestfile = 'regress-72773.js'; |
| 22 | var BUGNUMBER = 72773; |
| 23 | var summary = "Regression test: we shouldn't crash on this code"; |
| 24 | var status = ''; |
| 25 | var actual = ''; |
| 26 | var expect = ''; |
| 27 | var sToEval = ''; |
| 28 | |
| 29 | /* |
| 30 | * This code should produce an error, but not a crash. |
| 31 | * 'TypeError: Function.prototype.toString called on incompatible object' |
| 32 | */ |
| 33 | sToEval += 'function Cow(name){this.name = name;}' |
| 34 | sToEval += 'function Calf(str){this.name = str;}' |
| 35 | sToEval += 'Calf.prototype = Cow;' |
| 36 | sToEval += 'new Calf().toString();' |
| 37 | |
| 38 | status = 'Trying to catch an expected error'; |
| 39 | try |
| 40 | { |
| 41 | eval(sToEval); |
| 42 | } |
| 43 | catch(e) |
| 44 | { |
| 45 | actual = getJSClass(e); |
| 46 | expect = 'Error'; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | //---------------------------------------------------------------------------------------------- |
| 51 | test(); |
| 52 | //---------------------------------------------------------------------------------------------- |
| 53 | |
| 54 | |
| 55 | function test() |
| 56 | { |
| 57 | enterFunc ('test'); |
| 58 | printBugNumber(BUGNUMBER); |
| 59 | printStatus (summary); |
| 60 | |
| 61 | reportCompare(expect, actual, status); |
| 62 | |
| 63 | exitFunc ('test'); |
| 64 | } |