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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 testArguments(dcp, '{"type":"scriptId","target":' + f_script_id + ',"line":'
+ f_line + '}', true, false); | 110 testArguments(dcp, '{"type":"scriptId","target":' + f_script_id + ',"line":'
+ f_line + '}', true, false); |
111 testArguments(dcp, '{"type":"scriptId","target":' + g_script_id + ',"line":'
+ g_line + '}', true, false); | 111 testArguments(dcp, '{"type":"scriptId","target":' + g_script_id + ',"line":'
+ g_line + '}', true, false); |
112 testArguments(dcp, '{"type":"scriptId","target":' + h_script_id + ',"line":'
+ h_line + '}', true, false); | 112 testArguments(dcp, '{"type":"scriptId","target":' + h_script_id + ',"line":'
+ h_line + '}', true, false); |
113 | 113 |
114 mirror = debug.MakeMirror(f); | 114 mirror = debug.MakeMirror(f); |
115 testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', tru
e, false); | 115 testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', tru
e, false); |
116 mirror = debug.MakeMirror(o.a); | 116 mirror = debug.MakeMirror(o.a); |
117 testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', tru
e, false); | 117 testArguments(dcp, '{"type":"handle","target":' + mirror.handle() + '}', tru
e, false); |
118 | 118 |
| 119 testArguments(dcp, '{"type":"script","target":"sourceUrlScript","line":1}',
true, true); |
| 120 |
119 // Indicate that all was processed. | 121 // Indicate that all was processed. |
120 listenerComplete = true; | 122 listenerComplete = true; |
121 } | 123 } |
122 } catch (e) { | 124 } catch (e) { |
123 exception = e | 125 exception = e |
124 }; | 126 }; |
125 }; | 127 }; |
126 | 128 |
127 // Add the debug event listener. | 129 // Add the debug event listener. |
128 Debug.setListener(listener); | 130 Debug.setListener(listener); |
129 | 131 |
130 function f() { | 132 function f() { |
131 a=1 | 133 a=1 |
132 }; | 134 }; |
133 | 135 |
134 function g() { | 136 function g() { |
135 f(); | 137 f(); |
136 }; | 138 }; |
137 | 139 |
138 eval('function h(){}'); | 140 eval('function h(){}'); |
| 141 eval('function sourceUrlFunc() { a = 2; }\n//@ sourceURL=sourceUrlScript'); |
139 | 142 |
140 o = {a:function(){},b:function(){}} | 143 o = {a:function(){},b:function(){}} |
141 | 144 |
142 // Check the script ids for the test functions. | 145 // Check the script ids for the test functions. |
143 f_script_id = Debug.findScript(f).id; | 146 f_script_id = Debug.findScript(f).id; |
144 g_script_id = Debug.findScript(g).id; | 147 g_script_id = Debug.findScript(g).id; |
145 h_script_id = Debug.findScript(h).id; | 148 h_script_id = Debug.findScript(h).id; |
| 149 sourceURL_script_id = Debug.findScript(sourceUrlFunc).id; |
| 150 |
146 assertTrue(f_script_id > 0, "invalid script id for f"); | 151 assertTrue(f_script_id > 0, "invalid script id for f"); |
147 assertTrue(g_script_id > 0, "invalid script id for g"); | 152 assertTrue(g_script_id > 0, "invalid script id for g"); |
148 assertTrue(h_script_id > 0, "invalid script id for h"); | 153 assertTrue(h_script_id > 0, "invalid script id for h"); |
| 154 assertTrue(sourceURL_script_id > 0, "invalid script id for sourceUrlFunc"); |
149 assertEquals(f_script_id, g_script_id); | 155 assertEquals(f_script_id, g_script_id); |
150 | 156 |
151 // Get the source line for the test functions. | 157 // Get the source line for the test functions. |
152 f_line = Debug.findFunctionSourceLocation(f).line; | 158 f_line = Debug.findFunctionSourceLocation(f).line; |
153 g_line = Debug.findFunctionSourceLocation(g).line; | 159 g_line = Debug.findFunctionSourceLocation(g).line; |
154 h_line = Debug.findFunctionSourceLocation(h).line; | 160 h_line = Debug.findFunctionSourceLocation(h).line; |
155 assertTrue(f_line > 0, "invalid line for f"); | 161 assertTrue(f_line > 0, "invalid line for f"); |
156 assertTrue(g_line > 0, "invalid line for g"); | 162 assertTrue(g_line > 0, "invalid line for g"); |
157 assertTrue(f_line < g_line); | 163 assertTrue(f_line < g_line); |
158 assertEquals(h_line, 0, "invalid line for h"); | 164 assertEquals(h_line, 0, "invalid line for h"); |
159 | 165 |
160 // Set a break point and call to invoke the debug event listener. | 166 // Set a break point and call to invoke the debug event listener. |
161 Debug.setBreakPoint(g, 0, 0); | 167 Debug.setBreakPoint(g, 0, 0); |
162 g(); | 168 g(); |
163 | 169 |
164 // Make sure that the debug event listener vas invoked. | 170 // Make sure that the debug event listener was invoked. |
165 assertTrue(listenerComplete, "listener did not run to completion: " + exception)
; | 171 assertTrue(listenerComplete, "listener did not run to completion: " + exception)
; |
| 172 |
| 173 // Try setting breakpoint by url specified in sourceURL |
| 174 |
| 175 var breakListenerCalled = false; |
| 176 |
| 177 function breakListener(event) { |
| 178 if (event == Debug.DebugEvent.Break) |
| 179 breakListenerCalled = true; |
| 180 } |
| 181 |
| 182 Debug.setListener(breakListener); |
| 183 |
| 184 sourceUrlFunc(); |
| 185 |
| 186 assertTrue(breakListenerCalled, "Break listener not called on breakpoint set by
sourceURL"); |
OLD | NEW |