OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 // dont-delete. This is not specified, but allowing overwriting the | 52 // dont-delete. This is not specified, but allowing overwriting the |
53 // name property with a getter can leaks error objects from different | 53 // name property with a getter can leaks error objects from different |
54 // script tags in the same context in a browser setting. We therefore | 54 // script tags in the same context in a browser setting. We therefore |
55 // disallow changes to the name property on error objects. | 55 // disallow changes to the name property on error objects. |
56 assertEquals("ReferenceError", ReferenceError.prototype.name); | 56 assertEquals("ReferenceError", ReferenceError.prototype.name); |
57 delete ReferenceError.prototype.name; | 57 delete ReferenceError.prototype.name; |
58 assertEquals("ReferenceError", ReferenceError.prototype.name); | 58 assertEquals("ReferenceError", ReferenceError.prototype.name); |
59 ReferenceError.prototype.name = "not a reference error"; | 59 ReferenceError.prototype.name = "not a reference error"; |
60 assertEquals("ReferenceError", ReferenceError.prototype.name); | 60 assertEquals("ReferenceError", ReferenceError.prototype.name); |
61 | 61 |
62 // Check that message and name are not enumerable on Error objects. | |
63 var desc = Object.getOwnPropertyDescriptor(Error.prototype, 'name'); | |
64 assertFalse(desc['enumerable']); | |
65 desc = Object.getOwnPropertyDescriptor(Error.prototype, 'message'); | |
66 assertFalse(desc['enumerable']); | |
67 | |
68 var e = new Error("foobar"); | |
69 desc = Object.getOwnPropertyDescriptor(e, 'message'); | |
70 assertFalse(desc['enumerable']); | |
71 desc = Object.getOwnPropertyDescriptor(e, 'arguments'); | |
72 assertFalse(desc['enumerable']); | |
73 desc = Object.getOwnPropertyDescriptor(e, 'type'); | |
74 assertFalse(desc['enumerable']); | |
75 desc = Object.getOwnPropertyDescriptor(e, 'stack'); | |
76 assertFalse(desc['enumerable']); | |
77 | |
78 // Name is not an own property, test that it is not enumerable by running | |
79 // through all properties of e. | |
80 for (var v in e) { | |
Mads Ager (chromium)
2011/06/15 13:41:54
Error objects should have no enumerable properties
Rico
2011/06/15 13:54:33
Done, but I kept the assertions above (to guarante
| |
81 if (v == 'name') assertUnreachable(); | |
82 } | |
OLD | NEW |