Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: test/mjsunit/error-constructors.js

Issue 7172011: Make name and message non-enumerable on Error object (this is a partial fix for issue 1215) (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/messages.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 tested above, but in addition we should have no enumerable
79 // properties, so we simply assert that.
80 for (var v in e) {
81 assertUnreachable();
82 }
OLDNEW
« no previous file with comments | « src/messages.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698