| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 message = e.message; | 324 message = e.message; |
| 325 } | 325 } |
| 326 | 326 |
| 327 assertEquals("abc", message); | 327 assertEquals("abc", message); |
| 328 | 328 |
| 329 // Test that modifying Error.prepareStackTrace by itself works. | 329 // Test that modifying Error.prepareStackTrace by itself works. |
| 330 Error.prepareStackTrace = function() { Error.prepareStackTrace = "custom"; }; | 330 Error.prepareStackTrace = function() { Error.prepareStackTrace = "custom"; }; |
| 331 new Error().stack; | 331 new Error().stack; |
| 332 | 332 |
| 333 assertEquals("custom", Error.prepareStackTrace); | 333 assertEquals("custom", Error.prepareStackTrace); |
| 334 | |
| 335 // Check that the formatted stack trace can be set to undefined. | |
| 336 error = new Error(); | |
| 337 error.stack = undefined; | |
| 338 assertEquals(undefined, error.stack); | |
| 339 | |
| 340 // Check that the stack trace accessors are not forcibly set. | |
| 341 var my_error = {}; | |
| 342 Object.freeze(my_error); | |
| 343 assertThrows(function() { Error.captureStackTrace(my_error); }); | |
| 344 | |
| 345 my_error = {}; | |
| 346 Object.preventExtensions(my_error); | |
| 347 assertThrows(function() { Error.captureStackTrace(my_error); }); | |
| 348 | |
| 349 var fake_error = {}; | |
| 350 my_error = new Error(); | |
| 351 var stolen_getter = Object.getOwnPropertyDescriptor(my_error, 'stack').get; | |
| 352 Object.defineProperty(fake_error, 'stack', { get: stolen_getter }); | |
| 353 assertEquals(undefined, fake_error.stack); | |
| OLD | NEW |