Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: test/mjsunit/es6/debug-scope-default-param-with-eval.js

Issue 1961963002: [debugger] make strict eval-scope visible to debugging. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/debug-function-scopes.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5 // Flags: --expose-debug-as debug
6 6
7 // Test that the parameter initialization block scope set up for 7 // Test that the parameter initialization block scope set up for
8 // sloppy eval is visible to the debugger. 8 // sloppy eval is visible to the debugger.
9 9
10 var Debug = debug.Debug; 10 var Debug = debug.Debug;
11 var exception = null; 11 var exception = null;
12 var break_count = 0; 12 var break_count = 0;
13 13
14 function call_for_break() { 14 function call_for_break() {
15 return 5; 15 return 5;
16 } 16 }
17 17
18 function test(x = eval("var y = 7; debugger; y") + call_for_break()) { 18 function test(x = eval("var y = 7; debugger; y") + call_for_break()) {
19 return x; 19 return x;
20 } 20 }
21 21
22 function listener(event, exec_state, event_data, data) { 22 function listener(event, exec_state, event_data, data) {
23 if (event != Debug.DebugEvent.Break) return; 23 if (event != Debug.DebugEvent.Break) return;
24 try { 24 try {
25 var frame = exec_state.frame(0); 25 var frame = exec_state.frame(0);
26 var top_scope = frame.scope(0); 26 var block_scope;
27 assertTrue(top_scope.scopeObject().propertyNames().includes('y'));
28 assertEquals(7, top_scope.scopeObject().property('y').value().value());
29 if (break_count++ == 0) { 27 if (break_count++ == 0) {
30 // Inside eval. 28 // Inside eval.
31 assertEquals([ debug.ScopeType.Block, 29 assertEquals([ debug.ScopeType.Eval,
30 debug.ScopeType.Block,
32 debug.ScopeType.Closure, 31 debug.ScopeType.Closure,
33 debug.ScopeType.Script, 32 debug.ScopeType.Script,
34 debug.ScopeType.Global ], 33 debug.ScopeType.Global ],
35 frame.allScopes().map(s => s.scopeType())); 34 frame.allScopes().map(s => s.scopeType()));
36 exec_state.prepareStep(Debug.StepAction.StepOut); 35 exec_state.prepareStep(Debug.StepAction.StepOut);
36 block_scope = frame.scope(1);
37 } else { 37 } else {
38 // Outside of eval. 38 // Outside of eval.
39 assertEquals([ debug.ScopeType.Block, 39 assertEquals([ debug.ScopeType.Block,
40 debug.ScopeType.Local, 40 debug.ScopeType.Local,
41 debug.ScopeType.Script, 41 debug.ScopeType.Script,
42 debug.ScopeType.Global ], 42 debug.ScopeType.Global ],
43 frame.allScopes().map(s => s.scopeType())); 43 frame.allScopes().map(s => s.scopeType()));
44 block_scope = frame.scope(0);
44 } 45 }
46 assertTrue(block_scope.scopeObject().propertyNames().includes('y'));
47 assertEquals(7, block_scope.scopeObject().property('y').value().value());
45 } catch (e) { 48 } catch (e) {
49 print(e);
46 exception = e; 50 exception = e;
47 } 51 }
48 } 52 }
49 53
50 Debug.setListener(listener); 54 Debug.setListener(listener);
51 55
52 assertEquals(12, test()); 56 assertEquals(12, test());
53 57
54 Debug.setListener(null); 58 Debug.setListener(null);
55 59
56 assertNull(exception); 60 assertNull(exception);
57 assertEquals(2, break_count); 61 assertEquals(2, break_count);
OLDNEW
« no previous file with comments | « test/mjsunit/debug-function-scopes.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698