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 var test_y = false; | |
8 | |
9 function foo(a = 1) { | |
10 var x = 2; | |
11 debugger; | |
12 eval("var y = 3"); | |
13 test_y = true; | |
14 debugger; | |
15 } | |
16 | |
17 var exception = null; | |
18 var break_count = 0; | |
19 var Debug = debug.Debug; | |
20 var ScopeType = debug.ScopeType; | |
21 | |
22 function listener(event, exec_state) { | |
23 if (event != Debug.DebugEvent.Break) return; | |
24 try { | |
25 var scopes = exec_state.frame(0).allScopes(); | |
26 var expectation = [ ScopeType.Block, | |
27 ScopeType.Local, | |
28 ScopeType.Script, | |
29 ScopeType.Global ]; | |
30 assertEquals(expectation, scopes.map(x => x.scopeType())); | |
31 assertEquals(2, scopes[0].scopeObject().value().x); | |
32 if (test_y) assertEquals(3, scopes[0].scopeObject().value().y); | |
33 assertEquals(1, scopes[1].scopeObject().value().a); | |
34 break_count++; | |
35 } catch (e) { | |
36 print(e); | |
37 exception = e; | |
38 } | |
39 } | |
40 Debug.setListener(listener); | |
41 foo(); | |
42 | |
43 assertNull(exception); | |
44 assertEquals(2, break_count); | |
OLD | NEW |