| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --expose-debug-as debug | |
| 6 | 5 |
| 7 // Test that debug-evaluate doesn't crash when this is used before super() call | 6 // Test that debug-evaluate doesn't crash when this is used before super() call |
| 8 // in constructor. | 7 // in constructor. |
| 9 | 8 |
| 10 Debug = debug.Debug | 9 Debug = debug.Debug |
| 11 | 10 |
| 12 var result; | 11 var result; |
| 13 | 12 |
| 14 function listener(event, exec_state, event_data, data) | 13 function listener(event, exec_state, event_data, data) |
| 15 { | 14 { |
| 16 try { | 15 try { |
| 17 if (event == Debug.DebugEvent.Break) { | 16 if (event == Debug.DebugEvent.Break) { |
| 18 result = exec_state.frame(0).evaluate("this.a").value(); | 17 result = exec_state.frame(0).evaluate("this.a").value(); |
| 19 } | 18 } |
| 20 } catch (e) { | 19 } catch (e) { |
| 21 result = e.message; | 20 result = e.message; |
| 22 } | 21 } |
| 23 } | 22 } |
| 24 | 23 |
| 25 Debug.setListener(listener); | 24 Debug.setListener(listener); |
| 26 | 25 |
| 27 class A { constructor () { this.a = 239; } } | 26 class A { constructor () { this.a = 239; } } |
| 28 class B extends A { | 27 class B extends A { |
| 29 constructor () { | 28 constructor () { |
| 30 debugger; | 29 debugger; |
| 31 assertEquals("Cannot read property 'a' of undefined", result); | 30 assertTrue(result.indexOf("Cannot read property 'a' of undefined") >= 0); |
| 32 super(); | 31 super(); |
| 33 debugger; | 32 debugger; |
| 34 assertEquals(239, result); | 33 assertEquals(239, result); |
| 35 } | 34 } |
| 36 } | 35 } |
| 37 new B(); | 36 new B(); |
| 38 | 37 |
| 39 Debug.setListener(null); | 38 Debug.setListener(null); |
| OLD | NEW |