| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 can find the correct this value for an arrow | 6 // Test that debug-evaluate can find the correct this value for an arrow |
| 8 // function, if "this" is referenced within the arrow function scope. | 7 // function, if "this" is referenced within the arrow function scope. |
| 9 | 8 |
| 10 Debug = debug.Debug | 9 Debug = debug.Debug |
| 11 | 10 |
| 12 var break_count = 0; | 11 var break_count = 0; |
| 13 var exception = null; | 12 var exception = null; |
| 14 | 13 |
| 15 function listener(event, exec_state, event_data, data) { | 14 function listener(event, exec_state, event_data, data) { |
| 16 if (event != Debug.DebugEvent.Break) return; | 15 if (event != Debug.DebugEvent.Break) return; |
| 17 try { | 16 try { |
| 18 for (var i = 0; i < exec_state.frameCount() - 1; i++) { | 17 for (var i = 0; i < exec_state.frameCount() - 1; i++) { |
| 19 var frame = exec_state.frame(i); | 18 var frame = exec_state.frame(i); |
| 20 var this_value = frame.evaluate("this").value(); | 19 var this_value = frame.evaluate("'' + this").value(); |
| 21 var expected = frame.sourceLineText().match(/\/\/ (.*$)/)[1]; | 20 var expected = frame.sourceLineText().match(/\/\/ (.*$)/)[1]; |
| 22 print(expected, this_value, frame.sourceLineText()); | 21 print(expected, this_value, frame.sourceLineText()); |
| 23 assertEquals(String(expected), String(this_value)); | 22 assertEquals(String(expected), String(this_value)); |
| 24 } | 23 } |
| 25 break_count++; | 24 break_count++; |
| 26 } catch (e) { | 25 } catch (e) { |
| 27 exception = e; | 26 exception = e; |
| 28 print(e + e.stack); | 27 print(e + e.stack); |
| 29 } | 28 } |
| 30 } | 29 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 106 |
| 108 (() => { | 107 (() => { |
| 109 (() => this); | 108 (() => this); |
| 110 debugger; // [object global] | 109 debugger; // [object global] |
| 111 })(); | 110 })(); |
| 112 | 111 |
| 113 Debug.setListener(null); | 112 Debug.setListener(null); |
| 114 | 113 |
| 115 assertEquals(55, break_count); | 114 assertEquals(55, break_count); |
| 116 assertNull(exception); | 115 assertNull(exception); |
| OLD | NEW |