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

Side by Side Diff: test/mjsunit/stack-traces.js

Issue 1510173002: Revert of Make Error.prototype.toString spec compliant; and fix various side-effect-free error printing metho… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « test/mjsunit/regress/regress-crbug-523308.js ('k') | test/test262/test262.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 assertTrue(threw, "UnintendedCallerCensorship didn't throw"); 206 assertTrue(threw, "UnintendedCallerCensorship didn't throw");
207 } 207 }
208 208
209 // If an error occurs while the stack trace is being formatted it should 209 // If an error occurs while the stack trace is being formatted it should
210 // be handled gracefully. 210 // be handled gracefully.
211 function testErrorsDuringFormatting() { 211 function testErrorsDuringFormatting() {
212 function Nasty() { } 212 function Nasty() { }
213 Nasty.prototype.foo = function () { throw new RangeError(); }; 213 Nasty.prototype.foo = function () { throw new RangeError(); };
214 var n = new Nasty(); 214 var n = new Nasty();
215 n.__defineGetter__('constructor', function () { CONS_FAIL; }); 215 n.__defineGetter__('constructor', function () { CONS_FAIL; });
216 assertThrows(()=>n.foo(), RangeError); 216 var threw = false;
217 try {
218 n.foo();
219 } catch (e) {
220 threw = true;
221 assertTrue(e.stack.indexOf('<error: ReferenceError') != -1,
222 "ErrorsDuringFormatting didn't contain error: ReferenceError");
223 }
224 assertTrue(threw, "ErrorsDuringFormatting didn't throw");
225 threw = false;
217 // Now we can't even format the message saying that we couldn't format 226 // Now we can't even format the message saying that we couldn't format
218 // the stack frame. Put that in your pipe and smoke it! 227 // the stack frame. Put that in your pipe and smoke it!
219 ReferenceError.prototype.toString = function () { NESTED_FAIL; }; 228 ReferenceError.prototype.toString = function () { NESTED_FAIL; };
220 assertThrows(()=>n.foo(), RangeError); 229 try {
230 n.foo();
231 } catch (e) {
232 threw = true;
233 assertTrue(e.stack.indexOf('<error>') != -1,
234 "ErrorsDuringFormatting didn't contain <error>");
235 }
236 assertTrue(threw, "ErrorsDuringFormatting didnt' throw (2)");
221 } 237 }
222 238
223 239
224 // Poisonous object that throws a reference error if attempted converted to 240 // Poisonous object that throws a reference error if attempted converted to
225 // a primitive values. 241 // a primitive values.
226 var thrower = { valueOf: function() { FAIL; }, 242 var thrower = { valueOf: function() { FAIL; },
227 toString: function() { FAIL; } }; 243 toString: function() { FAIL; } };
228 244
229 // Tests that a native constructor function is included in the 245 // Tests that a native constructor function is included in the
230 // stack trace. 246 // stack trace.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 378
363 my_error = {}; 379 my_error = {};
364 Object.preventExtensions(my_error); 380 Object.preventExtensions(my_error);
365 assertThrows(function() { Error.captureStackTrace(my_error); }); 381 assertThrows(function() { Error.captureStackTrace(my_error); });
366 382
367 var fake_error = {}; 383 var fake_error = {};
368 my_error = new Error(); 384 my_error = new Error();
369 var stolen_getter = Object.getOwnPropertyDescriptor(my_error, 'stack').get; 385 var stolen_getter = Object.getOwnPropertyDescriptor(my_error, 'stack').get;
370 Object.defineProperty(fake_error, 'stack', { get: stolen_getter }); 386 Object.defineProperty(fake_error, 'stack', { get: stolen_getter });
371 assertEquals(undefined, fake_error.stack); 387 assertEquals(undefined, fake_error.stack);
OLDNEW
« no previous file with comments | « test/mjsunit/regress/regress-crbug-523308.js ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698