| 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 --no-analyze-environment-liveness | 5 // Flags: --expose-debug-as debug --no-analyze-environment-liveness |
| 6 | 6 |
| 7 // Test that debug-evaluate only resolves variables that are used by | 7 // Test that debug-evaluate only resolves variables that are used by |
| 8 // the function inside which we debug-evaluate. This is to avoid | 8 // the function inside which we debug-evaluate. This is to avoid |
| 9 // incorrect variable resolution when a context-allocated variable is | 9 // incorrect variable resolution when a context-allocated variable is |
| 10 // shadowed by a stack-allocated variable. | 10 // shadowed by a stack-allocated variable. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 value = frame.evaluate("x").value(); | 22 value = frame.evaluate("x").value(); |
| 23 } catch (e) { | 23 } catch (e) { |
| 24 value = e.name; | 24 value = e.name; |
| 25 } | 25 } |
| 26 print(frame.sourceLineText()); | 26 print(frame.sourceLineText()); |
| 27 var expected = frame.sourceLineText().match(/\/\/ (.*$)/)[1]; | 27 var expected = frame.sourceLineText().match(/\/\/ (.*$)/)[1]; |
| 28 assertEquals(String(expected), String(value)); | 28 assertEquals(String(expected), String(value)); |
| 29 } | 29 } |
| 30 assertEquals("[object global]", | 30 assertEquals("[object global]", |
| 31 String(exec_state.frame(0).evaluate("this").value())); | 31 String(exec_state.frame(0).evaluate("this").value())); |
| 32 assertEquals("y", exec_state.frame(0).evaluate("y").value()); | 32 exec_state.frame(0).evaluate("y = 'Y'"); |
| 33 assertEquals("a", exec_state.frame(0).evaluate("a").value()); | |
| 34 exec_state.frame(0).evaluate("a = 'A'"); | 33 exec_state.frame(0).evaluate("a = 'A'"); |
| 35 assertThrows(() => exec_state.frame(0).evaluate("z"), ReferenceError); | 34 assertThrows(() => exec_state.frame(0).evaluate("z"), ReferenceError); |
| 36 } catch (e) { | 35 } catch (e) { |
| 37 exception = e; | 36 exception = e; |
| 38 print(e + e.stack); | 37 print(e + e.stack); |
| 39 } | 38 } |
| 40 } | 39 } |
| 41 | 40 |
| 42 Debug.setListener(listener); | 41 Debug.setListener(listener); |
| 43 | 42 |
| 44 var a = "a"; | 43 var a = "a"; |
| 45 (function() { | 44 assertEquals("Y", (function() { |
| 46 var x = 1; // context allocate x | 45 var x = 1; // context allocate x |
| 47 (() => x); | 46 (() => x); |
| 48 var y = "y"; | 47 var y = "y"; |
| 49 var z = "z"; | 48 var z = "z"; |
| 50 (function() { | 49 (function() { |
| 51 var x = 2; // stack allocate shadowing x | 50 var x = 2; // stack allocate shadowing x |
| 52 (function() { | 51 (function() { |
| 53 y; // access y | 52 y; // access y |
| 54 debugger; // ReferenceError | 53 debugger; // ReferenceError |
| 55 })(); // 2 | 54 })(); // 2 |
| 56 })(); // 1 | 55 })(); // 1 |
| 57 return y; | 56 return y; |
| 58 })(); | 57 })()); |
| 59 | 58 |
| 60 assertEquals("A", a); | 59 assertEquals("A", a); |
| 61 a = "a"; | 60 a = "a"; |
| 62 | 61 |
| 63 (function() { | 62 assertEquals("Y", (function() { |
| 64 var x = 1; // context allocate x | 63 var x = 1; // context allocate x |
| 65 (() => x); | 64 (() => x); |
| 66 var y = "y"; | 65 var y = "y"; |
| 67 var z = "z"; | 66 var z = "z"; |
| 68 (function() { | 67 (function() { |
| 69 var x = 2; // stack allocate shadowing x | 68 var x = 2; // stack allocate shadowing x |
| 70 (() => { | 69 (() => { |
| 71 y; | 70 y; |
| 72 a; | 71 a; |
| 73 this; // context allocate receiver | 72 this; // context allocate receiver |
| 74 debugger; // ReferenceError | 73 debugger; // ReferenceError |
| 75 })(); // 2 | 74 })(); // 2 |
| 76 })(); // 1 | 75 })(); // 1 |
| 77 return y; | 76 return y; |
| 78 })(); | 77 })()); |
| 79 | 78 |
| 80 assertEquals("A", a); | 79 assertEquals("A", a); |
| 81 | 80 |
| 82 Debug.setListener(null); | 81 Debug.setListener(null); |
| 83 assertNull(exception); | 82 assertNull(exception); |
| OLD | NEW |