|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/licenses/publicdomain/ |
|
4 */ |
|
5 |
|
6 //----------------------------------------------------------------------------- |
|
7 var BUGNUMBER = 537863; |
|
8 var summary = |
|
9 'undefined, Infinity, and NaN global properties should not be writable'; |
|
10 |
|
11 print(BUGNUMBER + ": " + summary); |
|
12 |
|
13 /************** |
|
14 * BEGIN TEST * |
|
15 **************/ |
|
16 |
|
17 var desc, old, error; |
|
18 var global = this; |
|
19 |
|
20 var names = ["NaN", "Infinity", "undefined"]; |
|
21 |
|
22 for (var i = 0; i < names.length; i++) |
|
23 { |
|
24 var name = names[i]; |
|
25 desc = Object.getOwnPropertyDescriptor(global, name); |
|
26 assertEq(desc !== undefined, true, name + " should be present"); |
|
27 assertEq(desc.enumerable, false, name + " should not be enumerable"); |
|
28 assertEq(desc.configurable, false, name + " should not be configurable"); |
|
29 assertEq(desc.writable, false, name + " should not be writable"); |
|
30 |
|
31 old = global[name]; |
|
32 global[name] = 17; |
|
33 assertEq(global[name], old, name + " changed on setting?"); |
|
34 |
|
35 error = "before"; |
|
36 try |
|
37 { |
|
38 throw new TypeError("SpiderMonkey doesn't currently implement " + |
|
39 "strict-mode throwing when setting a readonly " + |
|
40 "property, not running this bit of test for now; " + |
|
41 "see bug 537873"); |
|
42 |
|
43 (function() { "use strict"; global[name] = 42; error = "didn't throw"; })(); |
|
44 } |
|
45 catch (e) |
|
46 { |
|
47 if (e instanceof TypeError) |
|
48 error = "typeerror"; |
|
49 else |
|
50 error = "bad exception: " + e; |
|
51 } |
|
52 assertEq(error, "typeerror", "wrong strict mode error setting " + name); |
|
53 } |
|
54 |
|
55 /******************************************************************************/ |
|
56 |
|
57 reportCompare(true, true); |
|
58 |
|
59 print("All tests passed!"); |