Index: test/mjsunit/stack-traces.js |
diff --git a/test/mjsunit/stack-traces.js b/test/mjsunit/stack-traces.js |
index 46a16eb87a2db857a00f8d7de060af09ffc2fa00..f80a627b24a87eae9fe00e5bd0a24c5b7f5af903 100644 |
--- a/test/mjsunit/stack-traces.js |
+++ b/test/mjsunit/stack-traces.js |
@@ -331,3 +331,23 @@ Error.prepareStackTrace = function() { Error.prepareStackTrace = "custom"; }; |
new Error().stack; |
assertEquals("custom", Error.prepareStackTrace); |
+ |
+// Check that the formatted stack trace can be set to undefined. |
+error = new Error(); |
+error.stack = undefined; |
+assertEquals(undefined, error.stack); |
+ |
+// Check that the stack trace accessors are not forcibly set. |
+var my_error = {}; |
+Object.freeze(my_error); |
+assertThrows(function() { Error.captureStackTrace(my_error); }); |
+ |
+my_error = {}; |
+Object.preventExtensions(my_error); |
+assertThrows(function() { Error.captureStackTrace(my_error); }); |
+ |
+var fake_error = {}; |
+my_error = new Error(); |
+var stolen_getter = Object.getOwnPropertyDescriptor(my_error, 'stack').get; |
+Object.defineProperty(fake_error, 'stack', { get: stolen_getter }); |
+assertEquals(undefined, fake_error.stack); |