OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 18 matching lines...) Expand all Loading... |
29 // Get the Debug object exposed from the debug context global object. | 29 // Get the Debug object exposed from the debug context global object. |
30 Debug = debug.Debug | 30 Debug = debug.Debug |
31 | 31 |
32 listenerComplete = false; | 32 listenerComplete = false; |
33 exception = false; | 33 exception = false; |
34 | 34 |
35 | 35 |
36 function h() { | 36 function h() { |
37 var a = 1; | 37 var a = 1; |
38 var b = 2; | 38 var b = 2; |
| 39 var eval = 5; // Overriding eval should not break anything. |
39 debugger; // Breakpoint. | 40 debugger; // Breakpoint. |
40 } | 41 } |
41 | 42 |
42 function checkFrame0(frame) { | 43 function checkFrame0(frame) { |
43 // Frame 0 (h) has normal variables a and b. | 44 // Frame 0 (h) has normal variables a and b. |
44 var count = frame.localCount(); | 45 var count = frame.localCount(); |
45 assertEquals(2, count); | 46 assertEquals(3, count); |
46 for (var i = 0; i < count; ++i) { | 47 for (var i = 0; i < count; ++i) { |
47 var name = frame.localName(i); | 48 var name = frame.localName(i); |
48 var value = frame.localValue(i).value(); | 49 var value = frame.localValue(i).value(); |
49 if (name == 'a') { | 50 if (name == 'a') { |
50 assertEquals(1, value); | 51 assertEquals(1, value); |
51 } else { | 52 } else if (name !='eval') { |
52 assertEquals('b', name); | 53 assertEquals('b', name); |
53 assertEquals(2, value); | 54 assertEquals(2, value); |
54 } | 55 } |
55 } | 56 } |
56 } | 57 } |
57 | 58 |
58 | 59 |
59 function g() { | 60 function g() { |
60 var a = 3; | 61 var a = 3; |
61 eval("var b = 4;"); | 62 eval("var b = 4;"); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 try { | 109 try { |
109 if (event == Debug.DebugEvent.Break) | 110 if (event == Debug.DebugEvent.Break) |
110 { | 111 { |
111 checkFrame0(exec_state.frame(0)); | 112 checkFrame0(exec_state.frame(0)); |
112 checkFrame1(exec_state.frame(1)); | 113 checkFrame1(exec_state.frame(1)); |
113 checkFrame2(exec_state.frame(2)); | 114 checkFrame2(exec_state.frame(2)); |
114 | 115 |
115 // Evaluating a and b on frames 0, 1 and 2 produces 1, 2, 3, 4, 5 and 6. | 116 // Evaluating a and b on frames 0, 1 and 2 produces 1, 2, 3, 4, 5 and 6. |
116 assertEquals(1, exec_state.frame(0).evaluate('a').value()); | 117 assertEquals(1, exec_state.frame(0).evaluate('a').value()); |
117 assertEquals(2, exec_state.frame(0).evaluate('b').value()); | 118 assertEquals(2, exec_state.frame(0).evaluate('b').value()); |
| 119 assertEquals(5, exec_state.frame(0).evaluate('eval').value()); |
118 assertEquals(3, exec_state.frame(1).evaluate('a').value()); | 120 assertEquals(3, exec_state.frame(1).evaluate('a').value()); |
119 assertEquals(4, exec_state.frame(1).evaluate('b').value()); | 121 assertEquals(4, exec_state.frame(1).evaluate('b').value()); |
| 122 assertEquals("function", |
| 123 typeof exec_state.frame(1).evaluate('eval').value()); |
120 assertEquals(5, exec_state.frame(2).evaluate('a').value()); | 124 assertEquals(5, exec_state.frame(2).evaluate('a').value()); |
121 assertEquals(6, exec_state.frame(2).evaluate('b').value()); | 125 assertEquals(6, exec_state.frame(2).evaluate('b').value()); |
122 | 126 assertEquals("function", |
| 127 typeof exec_state.frame(2).evaluate('eval').value()); |
123 // Indicate that all was processed. | 128 // Indicate that all was processed. |
124 listenerComplete = true; | 129 listenerComplete = true; |
125 } | 130 } |
126 } catch (e) { | 131 } catch (e) { |
127 exception = e | 132 exception = e |
| 133 print("Caught something. " + e + " " + e.stack); |
128 }; | 134 }; |
129 }; | 135 }; |
130 | 136 |
131 // Add the debug event listener. | 137 // Add the debug event listener. |
132 Debug.setListener(listener); | 138 Debug.setListener(listener); |
133 | 139 |
134 f(); | 140 f(); |
135 | 141 |
136 // Make sure that the debug event listener vas invoked. | 142 // Make sure that the debug event listener was invoked. |
| 143 assertFalse(exception, "exception in listener") |
137 assertTrue(listenerComplete); | 144 assertTrue(listenerComplete); |
138 assertFalse(exception, "exception in listener") | |
OLD | NEW |