]>
Commit | Line | Data |
---|---|---|
b37bf2e1 A |
1 | /* |
2 | * The contents of this file are subject to the Netscape Public | |
3 | * License Version 1.1 (the "License"); you may not use this file | |
4 | * except in compliance with the License. You may obtain a copy of | |
5 | * the License at http://www.mozilla.org/NPL/ | |
6 | * | |
7 | * Software distributed under the License is distributed on an "AS IS" | |
8 | * basis, WITHOUT WARRANTY OF ANY KIND, either expressed | |
9 | * or implied. See the License for the specific language governing | |
10 | * rights and limitations under the License. | |
11 | * | |
12 | * The Original Code is mozilla.org code. | |
13 | * | |
14 | * The Initial Developer of the Original Code is Netscape | |
15 | * Communications Corporation. Portions created by Netscape are | |
16 | * Copyright (C) 1998 Netscape Communications Corporation. All | |
17 | * Rights Reserved. | |
18 | * | |
19 | * Contributor(s): pschwartau@netscape.com | |
20 | * Date: 09 May 2001 | |
21 | * | |
22 | * SUMMARY: Regression test: we shouldn't crash on this code | |
23 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=72773 | |
24 | * | |
25 | * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property. | |
26 | * | |
27 | * Same as class-001.js - but testing user-defined types here, not native types. | |
28 | * Therefore we expect the [[Class]] property to equal 'Object' in each case - | |
29 | * | |
30 | * The getJSClass() function we use is in a utility file, e.g. "shell.js" | |
31 | */ | |
32 | //------------------------------------------------------------------------------------------------- | |
33 | var bug = 72773; | |
34 | var summary = "Regression test: we shouldn't crash on this code"; | |
35 | var status = ''; | |
36 | var actual = ''; | |
37 | var expect = ''; | |
38 | var sToEval = ''; | |
39 | ||
40 | /* | |
41 | * This code should produce an error, but not a crash. | |
42 | * 'TypeError: Function.prototype.toString called on incompatible object' | |
43 | */ | |
44 | sToEval += 'function Cow(name){this.name = name;}' | |
45 | sToEval += 'function Calf(str){this.name = str;}' | |
46 | sToEval += 'Calf.prototype = Cow;' | |
47 | sToEval += 'new Calf().toString();' | |
48 | ||
49 | status = 'Trying to catch an expected error'; | |
50 | try | |
51 | { | |
52 | eval(sToEval); | |
53 | } | |
54 | catch(e) | |
55 | { | |
56 | actual = getJSClass(e); | |
57 | expect = 'Error'; | |
58 | } | |
59 | ||
60 | ||
61 | //---------------------------------------------------------------------------------------------- | |
62 | test(); | |
63 | //---------------------------------------------------------------------------------------------- | |
64 | ||
65 | ||
66 | function test() | |
67 | { | |
68 | enterFunc ('test'); | |
69 | printBugNumber (bug); | |
70 | printStatus (summary); | |
71 | ||
72 | reportCompare(expect, actual, status); | |
73 | ||
74 | exitFunc ('test'); | |
75 | } |