Chromium Code Reviews| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 function a$b$c$d() { return FAIL; } | 87 function a$b$c$d() { return FAIL; } |
| 88 function Wookie() { } | 88 function Wookie() { } |
| 89 Wookie.prototype.d = a$b$c$d; | 89 Wookie.prototype.d = a$b$c$d; |
| 90 (new Wookie).d(); | 90 (new Wookie).d(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 function testAnonymousMethod() { | 93 function testAnonymousMethod() { |
| 94 (function () { FAIL }).call([1, 2, 3]); | 94 (function () { FAIL }).call([1, 2, 3]); |
| 95 } | 95 } |
| 96 | 96 |
| 97 function testMethodDisplayName() { | |
| 98 function gen(name, counter) { | |
| 99 var f = function() { | |
| 100 if (counter === 0) | |
| 101 FAIL; | |
|
aandrey
2015/02/11 15:50:40
nit: use { } in v8 code
kozy
2015/02/11 16:11:56
Done.
| |
| 102 gen(name, counter - 1)(); | |
| 103 }; | |
| 104 f.displayName = name + '_' + counter; | |
| 105 return f; | |
| 106 }; | |
| 107 gen('foo', 2)(); | |
| 108 } | |
| 109 | |
| 97 function CustomError(message, stripPoint) { | 110 function CustomError(message, stripPoint) { |
| 98 this.message = message; | 111 this.message = message; |
| 99 Error.captureStackTrace(this, stripPoint); | 112 Error.captureStackTrace(this, stripPoint); |
| 100 } | 113 } |
| 101 | 114 |
| 102 CustomError.prototype.toString = function () { | 115 CustomError.prototype.toString = function () { |
| 103 return "CustomError: " + this.message; | 116 return "CustomError: " + this.message; |
| 104 }; | 117 }; |
| 105 | 118 |
| 106 function testDefaultCustomError() { | 119 function testDefaultCustomError() { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 testTrace("testNestedEval", testNestedEval, ["eval at Inner (eval at Outer"]); | 267 testTrace("testNestedEval", testNestedEval, ["eval at Inner (eval at Outer"]); |
| 255 testTrace("testEvalWithSourceURL", testEvalWithSourceURL, | 268 testTrace("testEvalWithSourceURL", testEvalWithSourceURL, |
| 256 [ "at Doo (res://name:1:18)" ]); | 269 [ "at Doo (res://name:1:18)" ]); |
| 257 testTrace("testNestedEvalWithSourceURL", testNestedEvalWithSourceURL, | 270 testTrace("testNestedEvalWithSourceURL", testNestedEvalWithSourceURL, |
| 258 [" at Inner (res://inner-eval:1:20)", | 271 [" at Inner (res://inner-eval:1:20)", |
| 259 " at Outer (res://outer-eval:1:37)"]); | 272 " at Outer (res://outer-eval:1:37)"]); |
| 260 testTrace("testValue", testValue, ["at Number.causeError"]); | 273 testTrace("testValue", testValue, ["at Number.causeError"]); |
| 261 testTrace("testConstructor", testConstructor, ["new Plonk"]); | 274 testTrace("testConstructor", testConstructor, ["new Plonk"]); |
| 262 testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]); | 275 testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]); |
| 263 testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]); | 276 testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]); |
| 277 testTrace("testMethodDisplayName", testMethodDisplayName, | |
| 278 [" at foo_0", " at foo_1", " at foo_2 "]); | |
| 264 testTrace("testDefaultCustomError", testDefaultCustomError, | 279 testTrace("testDefaultCustomError", testDefaultCustomError, |
| 265 ["hep-hey", "new CustomError"], | 280 ["hep-hey", "new CustomError"], |
| 266 ["collectStackTrace"]); | 281 ["collectStackTrace"]); |
| 267 testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"], | 282 testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"], |
| 268 ["new CustomError", "collectStackTrace"]); | 283 ["new CustomError", "collectStackTrace"]); |
| 269 testTrace("testClassNames", testClassNames, | 284 testTrace("testClassNames", testClassNames, |
| 270 ["new MyObj", "MyObjCreator.Create"], ["as Create"]); | 285 ["new MyObj", "MyObjCreator.Create"], ["as Create"]); |
| 271 testCallerCensorship(); | 286 testCallerCensorship(); |
| 272 testUnintendedCallerCensorship(); | 287 testUnintendedCallerCensorship(); |
| 273 testErrorsDuringFormatting(); | 288 testErrorsDuringFormatting(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 | 359 |
| 345 my_error = {}; | 360 my_error = {}; |
| 346 Object.preventExtensions(my_error); | 361 Object.preventExtensions(my_error); |
| 347 assertThrows(function() { Error.captureStackTrace(my_error); }); | 362 assertThrows(function() { Error.captureStackTrace(my_error); }); |
| 348 | 363 |
| 349 var fake_error = {}; | 364 var fake_error = {}; |
| 350 my_error = new Error(); | 365 my_error = new Error(); |
| 351 var stolen_getter = Object.getOwnPropertyDescriptor(my_error, 'stack').get; | 366 var stolen_getter = Object.getOwnPropertyDescriptor(my_error, 'stack').get; |
| 352 Object.defineProperty(fake_error, 'stack', { get: stolen_getter }); | 367 Object.defineProperty(fake_error, 'stack', { get: stolen_getter }); |
| 353 assertEquals(undefined, fake_error.stack); | 368 assertEquals(undefined, fake_error.stack); |
| OLD | NEW |