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 === 4) { |
| 106 Object.defineProperty(f, 'name', {get: function(){ throw 239; }}); |
| 107 } else if (counter == 3) { |
| 108 Object.defineProperty(f, 'name', {value: 'boo' + '_' + counter}); |
| 109 } else { |
| 110 Object.defineProperty(f, 'name', {writable: true}); |
| 111 if (counter === 2) |
| 112 f.name = 42; |
| 113 else |
| 114 f.name = name + '_' + counter; |
| 115 } |
| 116 return f; |
| 117 } |
| 118 gen('foo', 4)(); |
| 119 } |
| 120 |
| 121 function testFunctionInferredName() { |
| 122 var f = function() { |
| 123 FAIL; |
| 124 } |
| 125 f(); |
| 126 } |
| 127 |
97 function CustomError(message, stripPoint) { | 128 function CustomError(message, stripPoint) { |
98 this.message = message; | 129 this.message = message; |
99 Error.captureStackTrace(this, stripPoint); | 130 Error.captureStackTrace(this, stripPoint); |
100 } | 131 } |
101 | 132 |
102 CustomError.prototype.toString = function () { | 133 CustomError.prototype.toString = function () { |
103 return "CustomError: " + this.message; | 134 return "CustomError: " + this.message; |
104 }; | 135 }; |
105 | 136 |
106 function testDefaultCustomError() { | 137 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"]); | 285 testTrace("testNestedEval", testNestedEval, ["eval at Inner (eval at Outer"]); |
255 testTrace("testEvalWithSourceURL", testEvalWithSourceURL, | 286 testTrace("testEvalWithSourceURL", testEvalWithSourceURL, |
256 [ "at Doo (res://name:1:18)" ]); | 287 [ "at Doo (res://name:1:18)" ]); |
257 testTrace("testNestedEvalWithSourceURL", testNestedEvalWithSourceURL, | 288 testTrace("testNestedEvalWithSourceURL", testNestedEvalWithSourceURL, |
258 [" at Inner (res://inner-eval:1:20)", | 289 [" at Inner (res://inner-eval:1:20)", |
259 " at Outer (res://outer-eval:1:37)"]); | 290 " at Outer (res://outer-eval:1:37)"]); |
260 testTrace("testValue", testValue, ["at Number.causeError"]); | 291 testTrace("testValue", testValue, ["at Number.causeError"]); |
261 testTrace("testConstructor", testConstructor, ["new Plonk"]); | 292 testTrace("testConstructor", testConstructor, ["new Plonk"]); |
262 testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]); | 293 testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]); |
263 testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]); | 294 testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]); |
| 295 testTrace("testFunctionName", testFunctionName, |
| 296 [" at foo_0 ", " at foo_1", " at foo ", " at boo_3 ", " at foo "]); |
| 297 testTrace("testFunctionInferredName", testFunctionInferredName, [" at f "]); |
264 testTrace("testDefaultCustomError", testDefaultCustomError, | 298 testTrace("testDefaultCustomError", testDefaultCustomError, |
265 ["hep-hey", "new CustomError"], | 299 ["hep-hey", "new CustomError"], |
266 ["collectStackTrace"]); | 300 ["collectStackTrace"]); |
267 testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"], | 301 testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"], |
268 ["new CustomError", "collectStackTrace"]); | 302 ["new CustomError", "collectStackTrace"]); |
269 testTrace("testClassNames", testClassNames, | 303 testTrace("testClassNames", testClassNames, |
270 ["new MyObj", "MyObjCreator.Create"], ["as Create"]); | 304 ["new MyObj", "MyObjCreator.Create"], ["as Create"]); |
271 testCallerCensorship(); | 305 testCallerCensorship(); |
272 testUnintendedCallerCensorship(); | 306 testUnintendedCallerCensorship(); |
273 testErrorsDuringFormatting(); | 307 testErrorsDuringFormatting(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 378 |
345 my_error = {}; | 379 my_error = {}; |
346 Object.preventExtensions(my_error); | 380 Object.preventExtensions(my_error); |
347 assertThrows(function() { Error.captureStackTrace(my_error); }); | 381 assertThrows(function() { Error.captureStackTrace(my_error); }); |
348 | 382 |
349 var fake_error = {}; | 383 var fake_error = {}; |
350 my_error = new Error(); | 384 my_error = new Error(); |
351 var stolen_getter = Object.getOwnPropertyDescriptor(my_error, 'stack').get; | 385 var stolen_getter = Object.getOwnPropertyDescriptor(my_error, 'stack').get; |
352 Object.defineProperty(fake_error, 'stack', { get: stolen_getter }); | 386 Object.defineProperty(fake_error, 'stack', { get: stolen_getter }); |
353 assertEquals(undefined, fake_error.stack); | 387 assertEquals(undefined, fake_error.stack); |
OLD | NEW |