|
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 * |
|
8 * Date: 14 April 2003 |
|
9 * SUMMARY: Prototype of predefined error objects should be DontEnum |
|
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=201989 |
|
11 * |
|
12 */ |
|
13 //----------------------------------------------------------------------------- |
|
14 var UBound = 0; |
|
15 var BUGNUMBER = 201989; |
|
16 var summary = 'Prototype of predefined error objects should be DontEnum'; |
|
17 var status = ''; |
|
18 var statusitems = []; |
|
19 var actual = ''; |
|
20 var actualvalues = []; |
|
21 var expect= ''; |
|
22 var expectedvalues = []; |
|
23 |
|
24 |
|
25 /* |
|
26 * Tests that |F.prototype| is not enumerable in |F| |
|
27 */ |
|
28 function testDontEnum(F) |
|
29 { |
|
30 var proto = F.prototype; |
|
31 |
|
32 for (var prop in F) |
|
33 { |
|
34 if (F[prop] === proto) |
|
35 return false; |
|
36 } |
|
37 return true; |
|
38 } |
|
39 |
|
40 |
|
41 var list = [ |
|
42 "Error", |
|
43 "ConversionError", |
|
44 "EvalError", |
|
45 "RangeError", |
|
46 "ReferenceError", |
|
47 "SyntaxError", |
|
48 "TypeError", |
|
49 "URIError" |
|
50 ]; |
|
51 |
|
52 |
|
53 for (i in list) |
|
54 { |
|
55 var F = this[list[i]]; |
|
56 |
|
57 // Test for |F|; e.g. Rhino defines |ConversionError| while SM does not. |
|
58 if (F) |
|
59 { |
|
60 status = 'Testing DontEnum attribute of |' + list[i] + '.prototype|'; |
|
61 actual = testDontEnum(F); |
|
62 expect = true; |
|
63 addThis(); |
|
64 } |
|
65 } |
|
66 |
|
67 |
|
68 |
|
69 //----------------------------------------------------------------------------- |
|
70 test(); |
|
71 //----------------------------------------------------------------------------- |
|
72 |
|
73 |
|
74 |
|
75 function addThis() |
|
76 { |
|
77 statusitems[UBound] = status; |
|
78 actualvalues[UBound] = actual; |
|
79 expectedvalues[UBound] = expect; |
|
80 UBound++; |
|
81 } |
|
82 |
|
83 |
|
84 function test() |
|
85 { |
|
86 enterFunc('test'); |
|
87 printBugNumber(BUGNUMBER); |
|
88 printStatus(summary); |
|
89 |
|
90 for (var i=0; i<UBound; i++) |
|
91 { |
|
92 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
93 } |
|
94 |
|
95 exitFunc ('test'); |
|
96 } |