OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --expose-debug-as debug | |
6 | |
7 // Test that the parameter initialization block scope set up for | |
8 // sloppy eval is visible to the debugger. | |
9 | |
10 var Debug = debug.Debug; | |
11 var exception = null; | |
12 var break_count = 0; | |
13 | |
14 function call_for_break() { | |
15 return 5; | |
16 } | |
17 | |
18 function test(x = eval("var y = 7; debugger; y") + call_for_break()) { | |
19 return x; | |
20 } | |
21 | |
22 function listener(event, exec_state, event_data, data) { | |
23 if (event != Debug.DebugEvent.Break) return; | |
24 try { | |
25 var frame = exec_state.frame(0); | |
26 var block_scope; | |
27 if (break_count++ == 0) { | |
28 // Inside eval. | |
29 assertEquals([ debug.ScopeType.Eval, | |
30 debug.ScopeType.Block, | |
31 debug.ScopeType.Closure, | |
32 debug.ScopeType.Script, | |
33 debug.ScopeType.Global ], | |
34 frame.allScopes().map(s => s.scopeType())); | |
35 exec_state.prepareStep(Debug.StepAction.StepOut); | |
36 block_scope = frame.scope(1); | |
37 } else { | |
38 // Outside of eval. | |
39 assertEquals([ debug.ScopeType.Block, | |
40 debug.ScopeType.Local, | |
41 debug.ScopeType.Script, | |
42 debug.ScopeType.Global ], | |
43 frame.allScopes().map(s => s.scopeType())); | |
44 block_scope = frame.scope(0); | |
45 } | |
46 assertTrue(block_scope.scopeObject().propertyNames().includes('y')); | |
47 assertEquals(7, block_scope.scopeObject().property('y').value().value()); | |
48 } catch (e) { | |
49 print(e); | |
50 exception = e; | |
51 } | |
52 } | |
53 | |
54 Debug.setListener(listener); | |
55 | |
56 assertEquals(12, test()); | |
57 | |
58 Debug.setListener(null); | |
59 | |
60 assertNull(exception); | |
61 assertEquals(2, break_count); | |
OLD | NEW |