| 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 |
* 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 BUGNUMBER = 72773; |
| 22 |
var summary = "Regression test: we shouldn't crash on this code"; |
| 23 |
var status = ''; |
| 24 |
var actual = ''; |
| 25 |
var expect = ''; |
| 26 |
var sToEval = ''; |
| 27 |
|
| 28 |
/* |
| 29 |
* This code should produce an error, but not a crash. |
| 30 |
* 'TypeError: Function.prototype.toString called on incompatible object' |
| 31 |
*/ |
| 32 |
sToEval += 'function Cow(name){this.name = name;}' |
| 33 |
sToEval += 'function Calf(str){this.name = str;}' |
| 34 |
sToEval += 'Calf.prototype = Cow;' |
| 35 |
sToEval += 'new Calf().toString();' |
| 36 |
|
| 37 |
status = 'Trying to catch an expected error'; |
| 38 |
try |
| 39 |
{ |
| 40 |
eval(sToEval); |
| 41 |
} |
| 42 |
catch(e) |
| 43 |
{ |
| 44 |
actual = getJSClass(e); |
| 45 |
expect = 'Error'; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
//---------------------------------------------------------------------------------------------- |
| 50 |
test(); |
| 51 |
//---------------------------------------------------------------------------------------------- |
| 52 |
|
| 53 |
|
| 54 |
function test() |
| 55 |
{ |
| 56 |
printBugNumber(BUGNUMBER); |
| 57 |
printStatus (summary); |
| 58 |
|
| 59 |
reportCompare(expect, actual, status); |
| 60 |
} |