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 testFunctionName() { | |
| 98 function gen(name, counter) { | |
| 99 var f = function foo() { | |
| 100 if (counter === 0) { | |
| 101 FAIL; | |
| 102 } | |
| 103 gen(name, counter - 1)(); | |
| 104 } | |
| 105 if (counter === 3) { | |
| 106 Object.defineProperty(f, 'name', {get: function(){ throw 239; }}); | |
| 107 } else { | |
| 108 Object.defineProperty(f, 'name', {writable: true}); | |
|
yurys
2015/03/06 11:11:26
Can you also test the case when value is passed as
kozy
2015/03/06 12:49:59
Done.
| |
| 109 if (counter === 2) | |
| 110 f.name = 42; | |
| 111 else | |
| 112 f.name = name + '_' + counter; | |
| 113 } | |
| 114 return f; | |
| 115 } | |
| 116 gen('foo', 3)(); | |
| 117 } | |
| 118 | |
| 97 function CustomError(message, stripPoint) { | 119 function CustomError(message, stripPoint) { |
| 98 this.message = message; | 120 this.message = message; |
| 99 Error.captureStackTrace(this, stripPoint); | 121 Error.captureStackTrace(this, stripPoint); |
| 100 } | 122 } |
| 101 | 123 |
| 102 CustomError.prototype.toString = function () { | 124 CustomError.prototype.toString = function () { |
| 103 return "CustomError: " + this.message; | 125 return "CustomError: " + this.message; |
| 104 }; | 126 }; |
| 105 | 127 |
| 106 function testDefaultCustomError() { | 128 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"]); | 276 testTrace("testNestedEval", testNestedEval, ["eval at Inner (eval at Outer"]); |
| 255 testTrace("testEvalWithSourceURL", testEvalWithSourceURL, | 277 testTrace("testEvalWithSourceURL", testEvalWithSourceURL, |
| 256 [ "at Doo (res://name:1:18)" ]); | 278 [ "at Doo (res://name:1:18)" ]); |
| 257 testTrace("testNestedEvalWithSourceURL", testNestedEvalWithSourceURL, | 279 testTrace("testNestedEvalWithSourceURL", testNestedEvalWithSourceURL, |
| 258 [" at Inner (res://inner-eval:1:20)", | 280 [" at Inner (res://inner-eval:1:20)", |
| 259 " at Outer (res://outer-eval:1:37)"]); | 281 " at Outer (res://outer-eval:1:37)"]); |
| 260 testTrace("testValue", testValue, ["at Number.causeError"]); | 282 testTrace("testValue", testValue, ["at Number.causeError"]); |
| 261 testTrace("testConstructor", testConstructor, ["new Plonk"]); | 283 testTrace("testConstructor", testConstructor, ["new Plonk"]); |
| 262 testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]); | 284 testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]); |
| 263 testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]); | 285 testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]); |
| 286 testTrace("testFunctionName", testFunctionName, | |
| 287 [" at foo_0 ", " at foo_1", " at foo ", " at foo "]); | |
| 264 testTrace("testDefaultCustomError", testDefaultCustomError, | 288 testTrace("testDefaultCustomError", testDefaultCustomError, |
| 265 ["hep-hey", "new CustomError"], | 289 ["hep-hey", "new CustomError"], |
| 266 ["collectStackTrace"]); | 290 ["collectStackTrace"]); |
| 267 testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"], | 291 testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"], |
| 268 ["new CustomError", "collectStackTrace"]); | 292 ["new CustomError", "collectStackTrace"]); |
| 269 testTrace("testClassNames", testClassNames, | 293 testTrace("testClassNames", testClassNames, |
| 270 ["new MyObj", "MyObjCreator.Create"], ["as Create"]); | 294 ["new MyObj", "MyObjCreator.Create"], ["as Create"]); |
| 271 testCallerCensorship(); | 295 testCallerCensorship(); |
| 272 testUnintendedCallerCensorship(); | 296 testUnintendedCallerCensorship(); |
| 273 testErrorsDuringFormatting(); | 297 testErrorsDuringFormatting(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 | 368 |
| 345 my_error = {}; | 369 my_error = {}; |
| 346 Object.preventExtensions(my_error); | 370 Object.preventExtensions(my_error); |
| 347 assertThrows(function() { Error.captureStackTrace(my_error); }); | 371 assertThrows(function() { Error.captureStackTrace(my_error); }); |
| 348 | 372 |
| 349 var fake_error = {}; | 373 var fake_error = {}; |
| 350 my_error = new Error(); | 374 my_error = new Error(); |
| 351 var stolen_getter = Object.getOwnPropertyDescriptor(my_error, 'stack').get; | 375 var stolen_getter = Object.getOwnPropertyDescriptor(my_error, 'stack').get; |
| 352 Object.defineProperty(fake_error, 'stack', { get: stolen_getter }); | 376 Object.defineProperty(fake_error, 'stack', { get: stolen_getter }); |
| 353 assertEquals(undefined, fake_error.stack); | 377 assertEquals(undefined, fake_error.stack); |
| OLD | NEW |