|
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 DontDelete |
|
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 DontDelete'; |
|
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 DontDelete |
|
27 */ |
|
28 function testDontDelete(F) |
|
29 { |
|
30 var e; |
|
31 var orig = F.prototype; |
|
32 try |
|
33 { |
|
34 delete F.prototype; |
|
35 } |
|
36 catch (e) |
|
37 { |
|
38 } |
|
39 return F.prototype === orig; |
|
40 } |
|
41 |
|
42 |
|
43 var list = [ |
|
44 "Error", |
|
45 "ConversionError", |
|
46 "EvalError", |
|
47 "RangeError", |
|
48 "ReferenceError", |
|
49 "SyntaxError", |
|
50 "TypeError", |
|
51 "URIError" |
|
52 ]; |
|
53 |
|
54 |
|
55 for (i in list) |
|
56 { |
|
57 var F = this[list[i]]; |
|
58 |
|
59 // Test for |F|; e.g. Rhino defines |ConversionError| while SM does not. |
|
60 if (F) |
|
61 { |
|
62 status = 'Testing DontDelete attribute of |' + list[i] + '.prototype|'; |
|
63 actual = testDontDelete(F); |
|
64 expect = true; |
|
65 addThis(); |
|
66 } |
|
67 } |
|
68 |
|
69 |
|
70 |
|
71 //----------------------------------------------------------------------------- |
|
72 test(); |
|
73 //----------------------------------------------------------------------------- |
|
74 |
|
75 |
|
76 |
|
77 function addThis() |
|
78 { |
|
79 statusitems[UBound] = status; |
|
80 actualvalues[UBound] = actual; |
|
81 expectedvalues[UBound] = expect; |
|
82 UBound++; |
|
83 } |
|
84 |
|
85 |
|
86 function test() |
|
87 { |
|
88 enterFunc('test'); |
|
89 printBugNumber(BUGNUMBER); |
|
90 printStatus(summary); |
|
91 |
|
92 for (var i=0; i<UBound; i++) |
|
93 { |
|
94 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
95 } |
|
96 |
|
97 exitFunc ('test'); |
|
98 } |