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 | 5 // Flags: --expose-debug-as debug |
6 | 6 |
7 // Get the Debug object exposed from the debug context global object. | 7 // Get the Debug object exposed from the debug context global object. |
8 Debug = debug.Debug | 8 Debug = debug.Debug |
9 | 9 |
10 listenerComplete = false; | 10 listenerComplete = false; |
11 breakPointCount = 0; | 11 breakPointCount = 0; |
| 12 exception = null; |
12 | 13 |
13 function listener(event, exec_state, event_data, data) { | 14 function listener(event, exec_state, event_data, data) { |
14 if (event == Debug.DebugEvent.Break) { | 15 if (event != Debug.DebugEvent.Break) return; |
| 16 try { |
15 breakPointCount++; | 17 breakPointCount++; |
16 if (breakPointCount == 1) { | 18 if (breakPointCount == 1) { |
17 // Break point in initializer for parameter `a`, invoked by | 19 // Break point in initializer for parameter `a`, invoked by |
18 // initializer for parameter `b` | 20 // initializer for parameter `b` |
19 assertEquals('default', exec_state.frame(1).evaluate('mode').value()); | 21 assertEquals('default', exec_state.frame(0).evaluate('mode').value()); |
20 | 22 assertTrue(exec_state.frame(1).evaluate('b').isUndefined()); |
21 // initializer for `b` can't refer to `b` | 23 assertTrue(exec_state.frame(1).evaluate('c').isUndefined()); |
22 assertThrows(function() { | |
23 exec_state.frame(1).evaluate('b').value(); | |
24 }, ReferenceError); | |
25 | |
26 assertThrows(function() { | |
27 exec_state.frame(1).evaluate('c'); | |
28 }, ReferenceError); | |
29 } else if (breakPointCount == 2) { | 24 } else if (breakPointCount == 2) { |
30 // Break point in IIFE initializer for parameter `c` | 25 // Break point in IIFE initializer for parameter `c` |
31 assertEquals('modeFn', exec_state.frame(1).evaluate('a.name').value()); | 26 assertEquals('modeFn', exec_state.frame(1).evaluate('a.name').value()); |
32 assertEquals('default', exec_state.frame(1).evaluate('b').value()); | 27 assertEquals('default', exec_state.frame(1).evaluate('b').value()); |
33 assertThrows(function() { | 28 assertTrue(exec_state.frame(1).evaluate('c').isUndefined()); |
34 exec_state.frame(1).evaluate('c'); | |
35 }, ReferenceError); | |
36 } else if (breakPointCount == 3) { | 29 } else if (breakPointCount == 3) { |
37 // Break point in function body --- `c` parameter is shadowed | 30 // Break point in function body --- `c` parameter is shadowed |
38 assertEquals('modeFn', exec_state.frame(0).evaluate('a.name').value()); | 31 assertEquals('modeFn', exec_state.frame(0).evaluate('a.name').value()); |
39 assertEquals('default', exec_state.frame(0).evaluate('b').value()); | 32 assertEquals('default', exec_state.frame(0).evaluate('b').value()); |
40 assertEquals('local', exec_state.frame(0).evaluate('d').value()); | 33 assertEquals('local', exec_state.frame(0).evaluate('d').value()); |
41 } | 34 } |
| 35 } catch (e) { |
| 36 exception = e; |
42 } | 37 } |
43 }; | 38 }; |
44 | 39 |
45 // Add the debug event listener. | 40 // Add the debug event listener. |
46 Debug.setListener(listener); | 41 Debug.setListener(listener); |
47 | 42 |
48 function f(a = function modeFn(mode) { debugger; return mode; }, | 43 function f(a = function modeFn(mode) { debugger; return mode; }, |
49 b = a("default"), | 44 b = a("default"), |
50 c = (function() { debugger; })()) { | 45 c = (function() { debugger; })()) { |
51 var d = 'local'; | 46 var d = 'local'; |
52 debugger; | 47 debugger; |
53 }; | 48 }; |
54 | 49 |
55 f(); | 50 f(); |
56 | 51 |
57 // Make sure that the debug event listener vas invoked. | 52 // Make sure that the debug event listener vas invoked. |
58 assertEquals(3, breakPointCount); | 53 assertEquals(3, breakPointCount); |
| 54 assertNull(exception); |
OLD | NEW |