| 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 exec_state.frame(0).evaluate("y = 'Y'"); | 32 assertEquals("y", exec_state.frame(0).evaluate("y").value()); |
| 33 assertEquals("a", exec_state.frame(0).evaluate("a").value()); |
| 33 exec_state.frame(0).evaluate("a = 'A'"); | 34 exec_state.frame(0).evaluate("a = 'A'"); |
| 34 assertThrows(() => exec_state.frame(0).evaluate("z"), ReferenceError); | 35 assertThrows(() => exec_state.frame(0).evaluate("z"), ReferenceError); |
| 35 } catch (e) { | 36 } catch (e) { |
| 36 exception = e; | 37 exception = e; |
| 37 print(e + e.stack); | 38 print(e + e.stack); |
| 38 } | 39 } |
| 39 } | 40 } |
| 40 | 41 |
| 41 Debug.setListener(listener); | 42 Debug.setListener(listener); |
| 42 | 43 |
| 43 var a = "a"; | 44 var a = "a"; |
| 44 assertEquals("Y", (function() { | 45 (function() { |
| 45 var x = 1; // context allocate x | 46 var x = 1; // context allocate x |
| 46 (() => x); | 47 (() => x); |
| 47 var y = "y"; | 48 var y = "y"; |
| 48 var z = "z"; | 49 var z = "z"; |
| 49 (function() { | 50 (function() { |
| 50 var x = 2; // stack allocate shadowing x | 51 var x = 2; // stack allocate shadowing x |
| 51 (function() { | 52 (function() { |
| 52 y; // access y | 53 y; // access y |
| 53 debugger; // ReferenceError | 54 debugger; // ReferenceError |
| 54 })(); // 2 | 55 })(); // 2 |
| 55 })(); // 1 | 56 })(); // 1 |
| 56 return y; | 57 return y; |
| 57 })()); | 58 })(); |
| 58 | 59 |
| 59 assertEquals("A", a); | 60 assertEquals("A", a); |
| 60 a = "a"; | 61 a = "a"; |
| 61 | 62 |
| 62 assertEquals("Y", (function() { | 63 (function() { |
| 63 var x = 1; // context allocate x | 64 var x = 1; // context allocate x |
| 64 (() => x); | 65 (() => x); |
| 65 var y = "y"; | 66 var y = "y"; |
| 66 var z = "z"; | 67 var z = "z"; |
| 67 (function() { | 68 (function() { |
| 68 var x = 2; // stack allocate shadowing x | 69 var x = 2; // stack allocate shadowing x |
| 69 (() => { | 70 (() => { |
| 70 y; | 71 y; |
| 71 a; | 72 a; |
| 72 this; // context allocate receiver | 73 this; // context allocate receiver |
| 73 debugger; // ReferenceError | 74 debugger; // ReferenceError |
| 74 })(); // 2 | 75 })(); // 2 |
| 75 })(); // 1 | 76 })(); // 1 |
| 76 return y; | 77 return y; |
| 77 })()); | 78 })(); |
| 78 | 79 |
| 79 assertEquals("A", a); | 80 assertEquals("A", a); |
| 80 | 81 |
| 81 Debug.setListener(null); | 82 Debug.setListener(null); |
| 82 assertNull(exception); | 83 assertNull(exception); |
| OLD | NEW |