OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --expose-debug-as debug | |
6 | |
7 // Test that debug-evaluate only resolves variables that are used by | |
8 // the function inside which we debug-evaluate. This is to avoid | |
9 // incorrect variable resolution when a context-allocated variable is | |
10 // shadowed by a stack-allocated variable. | |
11 | |
12 "use strict"; | |
13 | |
14 var Debug = debug.Debug | |
15 | |
16 var exception = null; | |
17 function listener(event, exec_state, event_data, data) { | |
18 if (event != Debug.DebugEvent.Break) return; | |
19 try { | |
20 exec_state.frame(0).evaluate("var x = 2"); | |
21 exec_state.frame(0).evaluate("'use strict'; let y = 3"); | |
22 exec_state.frame(0).evaluate("var z = 4"); | |
23 exec_state.frame(0).evaluate("function bar() { return 5; }"); | |
24 } catch (e) { | |
25 exception = e; | |
26 print(e + e.stack); | |
27 } | |
28 } | |
29 | |
30 Debug.setListener(listener); | |
31 | |
32 var z = 1; | |
33 | |
34 (function() { | |
35 debugger; | |
36 })(); | |
37 | |
38 assertEquals(2, x); // declaration | |
39 assertThrows(() => y, ReferenceError); // let-declaration does not stick | |
40 assertEquals(4, z); // re-declaration | |
41 assertEquals(5, bar()); // function declaration | |
42 | |
43 Debug.setListener(null); | |
44 assertNull(exception); | |
OLD | NEW |