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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } catch (e) { | 68 } catch (e) { |
69 assertTrue(e.stack.indexOf("rec1") > 0); | 69 assertTrue(e.stack.indexOf("rec1") > 0); |
70 assertInstanceof(e, RangeError); | 70 assertInstanceof(e, RangeError); |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 // Check setting/getting stack property on the prototype chain. | 74 // Check setting/getting stack property on the prototype chain. |
75 function testErrorPrototype(prototype) { | 75 function testErrorPrototype(prototype) { |
76 var object = {}; | 76 var object = {}; |
77 object.__proto__ = prototype; | 77 object.__proto__ = prototype; |
78 object.stack = "123"; // Overwriting stack property fails. | 78 object.stack = "123"; // Overwriting stack property succeeds. |
79 assertEquals(prototype.stack, object.stack); | 79 assertTrue(prototype.stack != object.stack); |
80 assertTrue("123" != prototype.stack); | 80 assertEquals("123", object.stack); |
81 } | 81 } |
82 | 82 |
83 try { | 83 try { |
84 rec1(0); | 84 rec1(0); |
85 } catch (e) { | 85 } catch (e) { |
86 e.stack; | 86 e.stack; |
87 testErrorPrototype(e); | 87 testErrorPrototype(e); |
88 } | 88 } |
89 | 89 |
90 try { | 90 try { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 assertEquals("abc", e.stack); | 144 assertEquals("abc", e.stack); |
145 } | 145 } |
146 | 146 |
147 Error.stackTraceLimit = 3; | 147 Error.stackTraceLimit = 3; |
148 Error = ""; // Overwrite Error in the global object. | 148 Error = ""; // Overwrite Error in the global object. |
149 try { | 149 try { |
150 rec1(0); | 150 rec1(0); |
151 } catch (e) { | 151 } catch (e) { |
152 assertEquals(4, e.stack.split('\n').length); | 152 assertEquals(4, e.stack.split('\n').length); |
153 } | 153 } |
OLD | NEW |