Index: test/mjsunit/error-constructors.js |
=================================================================== |
--- test/mjsunit/error-constructors.js (revision 8295) |
+++ test/mjsunit/error-constructors.js (working copy) |
@@ -59,3 +59,24 @@ |
ReferenceError.prototype.name = "not a reference error"; |
assertEquals("ReferenceError", ReferenceError.prototype.name); |
+// Check that message and name are not enumerable on Error objects. |
+var desc = Object.getOwnPropertyDescriptor(Error.prototype, 'name'); |
+assertFalse(desc['enumerable']); |
+desc = Object.getOwnPropertyDescriptor(Error.prototype, 'message'); |
+assertFalse(desc['enumerable']); |
+ |
+var e = new Error("foobar"); |
+desc = Object.getOwnPropertyDescriptor(e, 'message'); |
+assertFalse(desc['enumerable']); |
+desc = Object.getOwnPropertyDescriptor(e, 'arguments'); |
+assertFalse(desc['enumerable']); |
+desc = Object.getOwnPropertyDescriptor(e, 'type'); |
+assertFalse(desc['enumerable']); |
+desc = Object.getOwnPropertyDescriptor(e, 'stack'); |
+assertFalse(desc['enumerable']); |
+ |
+// Name is not an own property, test that it is not enumerable by running |
+// through all properties of e. |
+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
|
+ if (v == 'name') assertUnreachable(); |
+} |