OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } catch (e) { | 54 } catch (e) { |
55 assertTrue(e.stack.indexOf("rec1") > 0); | 55 assertTrue(e.stack.indexOf("rec1") > 0); |
56 assertInstanceof(e, RangeError); | 56 assertInstanceof(e, RangeError); |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 // Check setting/getting stack property on the prototype chain. | 60 // Check setting/getting stack property on the prototype chain. |
61 function testErrorPrototype(prototype) { | 61 function testErrorPrototype(prototype) { |
62 var object = {}; | 62 var object = {}; |
63 object.__proto__ = prototype; | 63 object.__proto__ = prototype; |
64 object.stack = "123"; // Overwriting stack property fails. | 64 object.stack = "123"; |
65 assertEquals(prototype.stack, object.stack); | 65 assertEquals("123", object.stack); |
66 assertTrue("123" != prototype.stack); | 66 assertTrue("123" != prototype.stack); |
67 } | 67 } |
68 | 68 |
69 try { | 69 try { |
70 rec1(0); | 70 rec1(0); |
71 } catch (e) { | 71 } catch (e) { |
72 e.stack; | 72 e.stack; |
73 testErrorPrototype(e); | 73 testErrorPrototype(e); |
74 } | 74 } |
75 | 75 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 rec1(0); | 119 rec1(0); |
120 } catch (e) { | 120 } catch (e) { |
121 assertTrue(e.stack.split('\n').length > 100); | 121 assertTrue(e.stack.split('\n').length > 100); |
122 } | 122 } |
123 | 123 |
124 Error.stackTraceLimit = "not a number"; | 124 Error.stackTraceLimit = "not a number"; |
125 try { | 125 try { |
126 rec1(0); | 126 rec1(0); |
127 } catch (e) { | 127 } catch (e) { |
128 assertEquals(undefined, e.stack); | 128 assertEquals(undefined, e.stack); |
129 e.stack = "abc"; | |
130 assertEquals("abc", e.stack); | |
131 } | 129 } |
132 | 130 |
133 Error.stackTraceLimit = 3; | 131 Error.stackTraceLimit = 3; |
134 Error = ""; // Overwrite Error in the global object. | 132 Error = ""; // Overwrite Error in the global object. |
135 try { | 133 try { |
136 rec1(0); | 134 rec1(0); |
137 } catch (e) { | 135 } catch (e) { |
138 assertEquals(4, e.stack.split('\n').length); | 136 assertEquals(4, e.stack.split('\n').length); |
139 } | 137 } |
OLD | NEW |