OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 global_template, | 147 global_template, |
148 global_object)) { | 148 global_object)) { |
149 context_->Enter(); | 149 context_->Enter(); |
150 } | 150 } |
151 inline ~DebugLocalContext() { | 151 inline ~DebugLocalContext() { |
152 context_->Exit(); | 152 context_->Exit(); |
153 } | 153 } |
154 inline v8::Local<v8::Context> context() { return context_; } | 154 inline v8::Local<v8::Context> context() { return context_; } |
155 inline v8::Context* operator->() { return *context_; } | 155 inline v8::Context* operator->() { return *context_; } |
156 inline v8::Context* operator*() { return *context_; } | 156 inline v8::Context* operator*() { return *context_; } |
| 157 inline v8::Isolate* GetIsolate() { return context_->GetIsolate(); } |
157 inline bool IsReady() { return !context_.IsEmpty(); } | 158 inline bool IsReady() { return !context_.IsEmpty(); } |
158 void ExposeDebug() { | 159 void ExposeDebug() { |
159 v8::internal::Isolate* isolate = | 160 v8::internal::Isolate* isolate = |
160 reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate()); | 161 reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate()); |
161 v8::internal::Factory* factory = isolate->factory(); | 162 v8::internal::Factory* factory = isolate->factory(); |
162 v8::internal::Debug* debug = isolate->debug(); | 163 v8::internal::Debug* debug = isolate->debug(); |
163 // Expose the debug context global object in the global object for testing. | 164 // Expose the debug context global object in the global object for testing. |
164 debug->Load(); | 165 debug->Load(); |
165 debug->debug_context()->set_security_token( | 166 debug->debug_context()->set_security_token( |
166 v8::Utils::OpenHandle(*context_)->security_token()); | 167 v8::Utils::OpenHandle(*context_)->security_token()); |
(...skipping 14 matching lines...) Expand all Loading... |
181 }; | 182 }; |
182 | 183 |
183 | 184 |
184 // --- H e l p e r F u n c t i o n s | 185 // --- H e l p e r F u n c t i o n s |
185 | 186 |
186 | 187 |
187 // Compile and run the supplied source and return the fequested function. | 188 // Compile and run the supplied source and return the fequested function. |
188 static v8::Local<v8::Function> CompileFunction(DebugLocalContext* env, | 189 static v8::Local<v8::Function> CompileFunction(DebugLocalContext* env, |
189 const char* source, | 190 const char* source, |
190 const char* function_name) { | 191 const char* function_name) { |
191 v8::Script::Compile(v8::String::New(source))->Run(); | 192 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source)) |
192 return v8::Local<v8::Function>::Cast( | 193 ->Run(); |
193 (*env)->Global()->Get(v8::String::New(function_name))); | 194 return v8::Local<v8::Function>::Cast((*env)->Global()->Get( |
| 195 v8::String::NewFromUtf8(env->GetIsolate(), function_name))); |
194 } | 196 } |
195 | 197 |
196 | 198 |
197 // Compile and run the supplied source and return the requested function. | 199 // Compile and run the supplied source and return the requested function. |
198 static v8::Local<v8::Function> CompileFunction(const char* source, | 200 static v8::Local<v8::Function> CompileFunction(v8::Isolate* isolate, |
| 201 const char* source, |
199 const char* function_name) { | 202 const char* function_name) { |
200 v8::Script::Compile(v8::String::New(source))->Run(); | 203 v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))->Run(); |
201 v8::Local<v8::Object> global = | 204 v8::Local<v8::Object> global = |
202 CcTest::isolate()->GetCurrentContext()->Global(); | 205 CcTest::isolate()->GetCurrentContext()->Global(); |
203 return v8::Local<v8::Function>::Cast( | 206 return v8::Local<v8::Function>::Cast( |
204 global->Get(v8::String::New(function_name))); | 207 global->Get(v8::String::NewFromUtf8(isolate, function_name))); |
205 } | 208 } |
206 | 209 |
207 | 210 |
208 // Is there any debug info for the function? | 211 // Is there any debug info for the function? |
209 static bool HasDebugInfo(v8::Handle<v8::Function> fun) { | 212 static bool HasDebugInfo(v8::Handle<v8::Function> fun) { |
210 Handle<v8::internal::JSFunction> f = v8::Utils::OpenHandle(*fun); | 213 Handle<v8::internal::JSFunction> f = v8::Utils::OpenHandle(*fun); |
211 Handle<v8::internal::SharedFunctionInfo> shared(f->shared()); | 214 Handle<v8::internal::SharedFunctionInfo> shared(f->shared()); |
212 return Debug::HasDebugInfo(shared); | 215 return Debug::HasDebugInfo(shared); |
213 } | 216 } |
214 | 217 |
(...skipping 14 matching lines...) Expand all Loading... |
229 | 232 |
230 // Set a break point in a function and return the associated break point | 233 // Set a break point in a function and return the associated break point |
231 // number. | 234 // number. |
232 static int SetBreakPoint(v8::Handle<v8::Function> fun, int position) { | 235 static int SetBreakPoint(v8::Handle<v8::Function> fun, int position) { |
233 return SetBreakPoint(v8::Utils::OpenHandle(*fun), position); | 236 return SetBreakPoint(v8::Utils::OpenHandle(*fun), position); |
234 } | 237 } |
235 | 238 |
236 | 239 |
237 // Set a break point in a function using the Debug object and return the | 240 // Set a break point in a function using the Debug object and return the |
238 // associated break point number. | 241 // associated break point number. |
239 static int SetBreakPointFromJS(const char* function_name, | 242 static int SetBreakPointFromJS(v8::Isolate* isolate, |
| 243 const char* function_name, |
240 int line, int position) { | 244 int line, int position) { |
241 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; | 245 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
242 OS::SNPrintF(buffer, | 246 OS::SNPrintF(buffer, |
243 "debug.Debug.setBreakPoint(%s,%d,%d)", | 247 "debug.Debug.setBreakPoint(%s,%d,%d)", |
244 function_name, line, position); | 248 function_name, line, position); |
245 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 249 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
246 v8::Handle<v8::String> str = v8::String::New(buffer.start()); | 250 v8::Handle<v8::String> str = v8::String::NewFromUtf8(isolate, buffer.start()); |
247 return v8::Script::Compile(str)->Run()->Int32Value(); | 251 return v8::Script::Compile(str)->Run()->Int32Value(); |
248 } | 252 } |
249 | 253 |
250 | 254 |
251 // Set a break point in a script identified by id using the global Debug object. | 255 // Set a break point in a script identified by id using the global Debug object. |
252 static int SetScriptBreakPointByIdFromJS(int script_id, int line, int column) { | 256 static int SetScriptBreakPointByIdFromJS(v8::Isolate* isolate, int script_id, |
| 257 int line, int column) { |
253 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; | 258 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
254 if (column >= 0) { | 259 if (column >= 0) { |
255 // Column specified set script break point on precise location. | 260 // Column specified set script break point on precise location. |
256 OS::SNPrintF(buffer, | 261 OS::SNPrintF(buffer, |
257 "debug.Debug.setScriptBreakPointById(%d,%d,%d)", | 262 "debug.Debug.setScriptBreakPointById(%d,%d,%d)", |
258 script_id, line, column); | 263 script_id, line, column); |
259 } else { | 264 } else { |
260 // Column not specified set script break point on line. | 265 // Column not specified set script break point on line. |
261 OS::SNPrintF(buffer, | 266 OS::SNPrintF(buffer, |
262 "debug.Debug.setScriptBreakPointById(%d,%d)", | 267 "debug.Debug.setScriptBreakPointById(%d,%d)", |
263 script_id, line); | 268 script_id, line); |
264 } | 269 } |
265 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 270 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
266 { | 271 { |
267 v8::TryCatch try_catch; | 272 v8::TryCatch try_catch; |
268 v8::Handle<v8::String> str = v8::String::New(buffer.start()); | 273 v8::Handle<v8::String> str = |
| 274 v8::String::NewFromUtf8(isolate, buffer.start()); |
269 v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run(); | 275 v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run(); |
270 CHECK(!try_catch.HasCaught()); | 276 CHECK(!try_catch.HasCaught()); |
271 return value->Int32Value(); | 277 return value->Int32Value(); |
272 } | 278 } |
273 } | 279 } |
274 | 280 |
275 | 281 |
276 // Set a break point in a script identified by name using the global Debug | 282 // Set a break point in a script identified by name using the global Debug |
277 // object. | 283 // object. |
278 static int SetScriptBreakPointByNameFromJS(const char* script_name, | 284 static int SetScriptBreakPointByNameFromJS(v8::Isolate* isolate, |
279 int line, int column) { | 285 const char* script_name, int line, |
| 286 int column) { |
280 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; | 287 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
281 if (column >= 0) { | 288 if (column >= 0) { |
282 // Column specified set script break point on precise location. | 289 // Column specified set script break point on precise location. |
283 OS::SNPrintF(buffer, | 290 OS::SNPrintF(buffer, |
284 "debug.Debug.setScriptBreakPointByName(\"%s\",%d,%d)", | 291 "debug.Debug.setScriptBreakPointByName(\"%s\",%d,%d)", |
285 script_name, line, column); | 292 script_name, line, column); |
286 } else { | 293 } else { |
287 // Column not specified set script break point on line. | 294 // Column not specified set script break point on line. |
288 OS::SNPrintF(buffer, | 295 OS::SNPrintF(buffer, |
289 "debug.Debug.setScriptBreakPointByName(\"%s\",%d)", | 296 "debug.Debug.setScriptBreakPointByName(\"%s\",%d)", |
290 script_name, line); | 297 script_name, line); |
291 } | 298 } |
292 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 299 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
293 { | 300 { |
294 v8::TryCatch try_catch; | 301 v8::TryCatch try_catch; |
295 v8::Handle<v8::String> str = v8::String::New(buffer.start()); | 302 v8::Handle<v8::String> str = |
| 303 v8::String::NewFromUtf8(isolate, buffer.start()); |
296 v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run(); | 304 v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run(); |
297 CHECK(!try_catch.HasCaught()); | 305 CHECK(!try_catch.HasCaught()); |
298 return value->Int32Value(); | 306 return value->Int32Value(); |
299 } | 307 } |
300 } | 308 } |
301 | 309 |
302 | 310 |
303 // Clear a break point. | 311 // Clear a break point. |
304 static void ClearBreakPoint(int break_point) { | 312 static void ClearBreakPoint(int break_point) { |
305 v8::internal::Isolate* isolate = CcTest::i_isolate(); | 313 v8::internal::Isolate* isolate = CcTest::i_isolate(); |
306 v8::internal::Debug* debug = isolate->debug(); | 314 v8::internal::Debug* debug = isolate->debug(); |
307 debug->ClearBreakPoint( | 315 debug->ClearBreakPoint( |
308 Handle<Object>(v8::internal::Smi::FromInt(break_point), isolate)); | 316 Handle<Object>(v8::internal::Smi::FromInt(break_point), isolate)); |
309 } | 317 } |
310 | 318 |
311 | 319 |
312 // Clear a break point using the global Debug object. | 320 // Clear a break point using the global Debug object. |
313 static void ClearBreakPointFromJS(int break_point_number) { | 321 static void ClearBreakPointFromJS(v8::Isolate* isolate, |
| 322 int break_point_number) { |
314 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; | 323 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
315 OS::SNPrintF(buffer, | 324 OS::SNPrintF(buffer, |
316 "debug.Debug.clearBreakPoint(%d)", | 325 "debug.Debug.clearBreakPoint(%d)", |
317 break_point_number); | 326 break_point_number); |
318 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 327 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
319 v8::Script::Compile(v8::String::New(buffer.start()))->Run(); | 328 v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run(); |
320 } | 329 } |
321 | 330 |
322 | 331 |
323 static void EnableScriptBreakPointFromJS(int break_point_number) { | 332 static void EnableScriptBreakPointFromJS(v8::Isolate* isolate, |
| 333 int break_point_number) { |
324 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; | 334 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
325 OS::SNPrintF(buffer, | 335 OS::SNPrintF(buffer, |
326 "debug.Debug.enableScriptBreakPoint(%d)", | 336 "debug.Debug.enableScriptBreakPoint(%d)", |
327 break_point_number); | 337 break_point_number); |
328 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 338 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
329 v8::Script::Compile(v8::String::New(buffer.start()))->Run(); | 339 v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run(); |
330 } | 340 } |
331 | 341 |
332 | 342 |
333 static void DisableScriptBreakPointFromJS(int break_point_number) { | 343 static void DisableScriptBreakPointFromJS(v8::Isolate* isolate, |
| 344 int break_point_number) { |
334 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; | 345 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
335 OS::SNPrintF(buffer, | 346 OS::SNPrintF(buffer, |
336 "debug.Debug.disableScriptBreakPoint(%d)", | 347 "debug.Debug.disableScriptBreakPoint(%d)", |
337 break_point_number); | 348 break_point_number); |
338 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 349 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
339 v8::Script::Compile(v8::String::New(buffer.start()))->Run(); | 350 v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run(); |
340 } | 351 } |
341 | 352 |
342 | 353 |
343 static void ChangeScriptBreakPointConditionFromJS(int break_point_number, | 354 static void ChangeScriptBreakPointConditionFromJS(v8::Isolate* isolate, |
| 355 int break_point_number, |
344 const char* condition) { | 356 const char* condition) { |
345 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; | 357 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
346 OS::SNPrintF(buffer, | 358 OS::SNPrintF(buffer, |
347 "debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")", | 359 "debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")", |
348 break_point_number, condition); | 360 break_point_number, condition); |
349 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 361 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
350 v8::Script::Compile(v8::String::New(buffer.start()))->Run(); | 362 v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run(); |
351 } | 363 } |
352 | 364 |
353 | 365 |
354 static void ChangeScriptBreakPointIgnoreCountFromJS(int break_point_number, | 366 static void ChangeScriptBreakPointIgnoreCountFromJS(v8::Isolate* isolate, |
| 367 int break_point_number, |
355 int ignoreCount) { | 368 int ignoreCount) { |
356 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; | 369 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
357 OS::SNPrintF(buffer, | 370 OS::SNPrintF(buffer, |
358 "debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)", | 371 "debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)", |
359 break_point_number, ignoreCount); | 372 break_point_number, ignoreCount); |
360 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 373 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
361 v8::Script::Compile(v8::String::New(buffer.start()))->Run(); | 374 v8::Script::Compile(v8::String::NewFromUtf8(isolate, buffer.start()))->Run(); |
362 } | 375 } |
363 | 376 |
364 | 377 |
365 // Change break on exception. | 378 // Change break on exception. |
366 static void ChangeBreakOnException(bool caught, bool uncaught) { | 379 static void ChangeBreakOnException(bool caught, bool uncaught) { |
367 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); | 380 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); |
368 debug->ChangeBreakOnException(v8::internal::BreakException, caught); | 381 debug->ChangeBreakOnException(v8::internal::BreakException, caught); |
369 debug->ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught); | 382 debug->ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught); |
370 } | 383 } |
371 | 384 |
372 | 385 |
373 // Change break on exception using the global Debug object. | 386 // Change break on exception using the global Debug object. |
374 static void ChangeBreakOnExceptionFromJS(bool caught, bool uncaught) { | 387 static void ChangeBreakOnExceptionFromJS(v8::Isolate* isolate, bool caught, |
| 388 bool uncaught) { |
375 if (caught) { | 389 if (caught) { |
376 v8::Script::Compile( | 390 v8::Script::Compile( |
377 v8::String::New("debug.Debug.setBreakOnException()"))->Run(); | 391 v8::String::NewFromUtf8(isolate, "debug.Debug.setBreakOnException()")) |
| 392 ->Run(); |
378 } else { | 393 } else { |
379 v8::Script::Compile( | 394 v8::Script::Compile( |
380 v8::String::New("debug.Debug.clearBreakOnException()"))->Run(); | 395 v8::String::NewFromUtf8(isolate, "debug.Debug.clearBreakOnException()")) |
| 396 ->Run(); |
381 } | 397 } |
382 if (uncaught) { | 398 if (uncaught) { |
383 v8::Script::Compile( | 399 v8::Script::Compile( |
384 v8::String::New("debug.Debug.setBreakOnUncaughtException()"))->Run(); | 400 v8::String::NewFromUtf8( |
| 401 isolate, "debug.Debug.setBreakOnUncaughtException()"))->Run(); |
385 } else { | 402 } else { |
386 v8::Script::Compile( | 403 v8::Script::Compile( |
387 v8::String::New("debug.Debug.clearBreakOnUncaughtException()"))->Run(); | 404 v8::String::NewFromUtf8( |
| 405 isolate, "debug.Debug.clearBreakOnUncaughtException()"))->Run(); |
388 } | 406 } |
389 } | 407 } |
390 | 408 |
391 | 409 |
392 // Prepare to step to next break location. | 410 // Prepare to step to next break location. |
393 static void PrepareStep(StepAction step_action) { | 411 static void PrepareStep(StepAction step_action) { |
394 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); | 412 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); |
395 debug->PrepareStep(step_action, 1, StackFrame::NO_ID); | 413 debug->PrepareStep(step_action, 1, StackFrame::NO_ID); |
396 } | 414 } |
397 | 415 |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 // When hitting a debug event listener there must be a break set. | 810 // When hitting a debug event listener there must be a break set. |
793 CHECK_NE(debug->break_id(), 0); | 811 CHECK_NE(debug->break_id(), 0); |
794 | 812 |
795 // Count the number of breaks. | 813 // Count the number of breaks. |
796 if (event == v8::Break) { | 814 if (event == v8::Break) { |
797 break_point_hit_count++; | 815 break_point_hit_count++; |
798 } else if (event == v8::Exception) { | 816 } else if (event == v8::Exception) { |
799 exception_hit_count++; | 817 exception_hit_count++; |
800 | 818 |
801 // Check whether the exception was uncaught. | 819 // Check whether the exception was uncaught. |
802 v8::Local<v8::String> fun_name = v8::String::New("uncaught"); | 820 v8::Local<v8::String> fun_name = |
| 821 v8::String::NewFromUtf8(CcTest::isolate(), "uncaught"); |
803 v8::Local<v8::Function> fun = | 822 v8::Local<v8::Function> fun = |
804 v8::Local<v8::Function>::Cast(event_data->Get(fun_name)); | 823 v8::Local<v8::Function>::Cast(event_data->Get(fun_name)); |
805 v8::Local<v8::Value> result = fun->Call(event_data, 0, NULL); | 824 v8::Local<v8::Value> result = fun->Call(event_data, 0, NULL); |
806 if (result->IsTrue()) { | 825 if (result->IsTrue()) { |
807 uncaught_exception_hit_count++; | 826 uncaught_exception_hit_count++; |
808 } | 827 } |
809 } | 828 } |
810 | 829 |
811 // Collect the JavsScript stack height if the function frame_count is | 830 // Collect the JavsScript stack height if the function frame_count is |
812 // compiled. | 831 // compiled. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 const v8::Debug::EventDetails& event_details) { | 868 const v8::Debug::EventDetails& event_details) { |
850 v8::DebugEvent event = event_details.GetEvent(); | 869 v8::DebugEvent event = event_details.GetEvent(); |
851 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); | 870 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); |
852 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); | 871 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); |
853 // When hitting a debug event listener there must be a break set. | 872 // When hitting a debug event listener there must be a break set. |
854 CHECK_NE(debug->break_id(), 0); | 873 CHECK_NE(debug->break_id(), 0); |
855 | 874 |
856 if (event == v8::Break) { | 875 if (event == v8::Break) { |
857 for (int i = 0; checks[i].expr != NULL; i++) { | 876 for (int i = 0; checks[i].expr != NULL; i++) { |
858 const int argc = 3; | 877 const int argc = 3; |
859 v8::Handle<v8::Value> argv[argc] = { exec_state, | 878 v8::Handle<v8::Value> argv[argc] = { |
860 v8::String::New(checks[i].expr), | 879 exec_state, |
861 checks[i].expected }; | 880 v8::String::NewFromUtf8(CcTest::isolate(), checks[i].expr), |
| 881 checks[i].expected}; |
862 v8::Handle<v8::Value> result = | 882 v8::Handle<v8::Value> result = |
863 evaluate_check_function->Call(exec_state, argc, argv); | 883 evaluate_check_function->Call(exec_state, argc, argv); |
864 if (!result->IsTrue()) { | 884 if (!result->IsTrue()) { |
865 v8::String::Utf8Value utf8(checks[i].expected->ToString()); | 885 v8::String::Utf8Value utf8(checks[i].expected->ToString()); |
866 V8_Fatal(__FILE__, __LINE__, "%s != %s", checks[i].expr, *utf8); | 886 V8_Fatal(__FILE__, __LINE__, "%s != %s", checks[i].expr, *utf8); |
867 } | 887 } |
868 } | 888 } |
869 } | 889 } |
870 } | 890 } |
871 | 891 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 } | 1200 } |
1181 | 1201 |
1182 | 1202 |
1183 // Test that a break point can be set at an IC store location. | 1203 // Test that a break point can be set at an IC store location. |
1184 TEST(BreakPointICStore) { | 1204 TEST(BreakPointICStore) { |
1185 break_point_hit_count = 0; | 1205 break_point_hit_count = 0; |
1186 DebugLocalContext env; | 1206 DebugLocalContext env; |
1187 v8::HandleScope scope(env->GetIsolate()); | 1207 v8::HandleScope scope(env->GetIsolate()); |
1188 | 1208 |
1189 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 1209 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1190 v8::Script::Compile(v8::String::New("function foo(){bar=0;}"))->Run(); | 1210 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
1191 v8::Local<v8::Function> foo = | 1211 "function foo(){bar=0;}"))->Run(); |
1192 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); | 1212 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 1213 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
1193 | 1214 |
1194 // Run without breakpoints. | 1215 // Run without breakpoints. |
1195 foo->Call(env->Global(), 0, NULL); | 1216 foo->Call(env->Global(), 0, NULL); |
1196 CHECK_EQ(0, break_point_hit_count); | 1217 CHECK_EQ(0, break_point_hit_count); |
1197 | 1218 |
1198 // Run with breakpoint | 1219 // Run with breakpoint |
1199 int bp = SetBreakPoint(foo, 0); | 1220 int bp = SetBreakPoint(foo, 0); |
1200 foo->Call(env->Global(), 0, NULL); | 1221 foo->Call(env->Global(), 0, NULL); |
1201 CHECK_EQ(1, break_point_hit_count); | 1222 CHECK_EQ(1, break_point_hit_count); |
1202 foo->Call(env->Global(), 0, NULL); | 1223 foo->Call(env->Global(), 0, NULL); |
1203 CHECK_EQ(2, break_point_hit_count); | 1224 CHECK_EQ(2, break_point_hit_count); |
1204 | 1225 |
1205 // Run without breakpoints. | 1226 // Run without breakpoints. |
1206 ClearBreakPoint(bp); | 1227 ClearBreakPoint(bp); |
1207 foo->Call(env->Global(), 0, NULL); | 1228 foo->Call(env->Global(), 0, NULL); |
1208 CHECK_EQ(2, break_point_hit_count); | 1229 CHECK_EQ(2, break_point_hit_count); |
1209 | 1230 |
1210 v8::Debug::SetDebugEventListener2(NULL); | 1231 v8::Debug::SetDebugEventListener2(NULL); |
1211 CheckDebuggerUnloaded(); | 1232 CheckDebuggerUnloaded(); |
1212 } | 1233 } |
1213 | 1234 |
1214 | 1235 |
1215 // Test that a break point can be set at an IC load location. | 1236 // Test that a break point can be set at an IC load location. |
1216 TEST(BreakPointICLoad) { | 1237 TEST(BreakPointICLoad) { |
1217 break_point_hit_count = 0; | 1238 break_point_hit_count = 0; |
1218 DebugLocalContext env; | 1239 DebugLocalContext env; |
1219 v8::HandleScope scope(env->GetIsolate()); | 1240 v8::HandleScope scope(env->GetIsolate()); |
1220 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 1241 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1221 v8::Script::Compile(v8::String::New("bar=1"))->Run(); | 1242 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "bar=1")) |
1222 v8::Script::Compile(v8::String::New("function foo(){var x=bar;}"))->Run(); | 1243 ->Run(); |
1223 v8::Local<v8::Function> foo = | 1244 v8::Script::Compile( |
1224 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); | 1245 v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){var x=bar;}")) |
| 1246 ->Run(); |
| 1247 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 1248 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
1225 | 1249 |
1226 // Run without breakpoints. | 1250 // Run without breakpoints. |
1227 foo->Call(env->Global(), 0, NULL); | 1251 foo->Call(env->Global(), 0, NULL); |
1228 CHECK_EQ(0, break_point_hit_count); | 1252 CHECK_EQ(0, break_point_hit_count); |
1229 | 1253 |
1230 // Run with breakpoint. | 1254 // Run with breakpoint. |
1231 int bp = SetBreakPoint(foo, 0); | 1255 int bp = SetBreakPoint(foo, 0); |
1232 foo->Call(env->Global(), 0, NULL); | 1256 foo->Call(env->Global(), 0, NULL); |
1233 CHECK_EQ(1, break_point_hit_count); | 1257 CHECK_EQ(1, break_point_hit_count); |
1234 foo->Call(env->Global(), 0, NULL); | 1258 foo->Call(env->Global(), 0, NULL); |
1235 CHECK_EQ(2, break_point_hit_count); | 1259 CHECK_EQ(2, break_point_hit_count); |
1236 | 1260 |
1237 // Run without breakpoints. | 1261 // Run without breakpoints. |
1238 ClearBreakPoint(bp); | 1262 ClearBreakPoint(bp); |
1239 foo->Call(env->Global(), 0, NULL); | 1263 foo->Call(env->Global(), 0, NULL); |
1240 CHECK_EQ(2, break_point_hit_count); | 1264 CHECK_EQ(2, break_point_hit_count); |
1241 | 1265 |
1242 v8::Debug::SetDebugEventListener2(NULL); | 1266 v8::Debug::SetDebugEventListener2(NULL); |
1243 CheckDebuggerUnloaded(); | 1267 CheckDebuggerUnloaded(); |
1244 } | 1268 } |
1245 | 1269 |
1246 | 1270 |
1247 // Test that a break point can be set at an IC call location. | 1271 // Test that a break point can be set at an IC call location. |
1248 TEST(BreakPointICCall) { | 1272 TEST(BreakPointICCall) { |
1249 break_point_hit_count = 0; | 1273 break_point_hit_count = 0; |
1250 DebugLocalContext env; | 1274 DebugLocalContext env; |
1251 v8::HandleScope scope(env->GetIsolate()); | 1275 v8::HandleScope scope(env->GetIsolate()); |
1252 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 1276 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1253 v8::Script::Compile(v8::String::New("function bar(){}"))->Run(); | 1277 v8::Script::Compile( |
1254 v8::Script::Compile(v8::String::New("function foo(){bar();}"))->Run(); | 1278 v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){}"))->Run(); |
1255 v8::Local<v8::Function> foo = | 1279 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
1256 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); | 1280 "function foo(){bar();}"))->Run(); |
| 1281 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 1282 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
1257 | 1283 |
1258 // Run without breakpoints. | 1284 // Run without breakpoints. |
1259 foo->Call(env->Global(), 0, NULL); | 1285 foo->Call(env->Global(), 0, NULL); |
1260 CHECK_EQ(0, break_point_hit_count); | 1286 CHECK_EQ(0, break_point_hit_count); |
1261 | 1287 |
1262 // Run with breakpoint | 1288 // Run with breakpoint |
1263 int bp = SetBreakPoint(foo, 0); | 1289 int bp = SetBreakPoint(foo, 0); |
1264 foo->Call(env->Global(), 0, NULL); | 1290 foo->Call(env->Global(), 0, NULL); |
1265 CHECK_EQ(1, break_point_hit_count); | 1291 CHECK_EQ(1, break_point_hit_count); |
1266 foo->Call(env->Global(), 0, NULL); | 1292 foo->Call(env->Global(), 0, NULL); |
1267 CHECK_EQ(2, break_point_hit_count); | 1293 CHECK_EQ(2, break_point_hit_count); |
1268 | 1294 |
1269 // Run without breakpoints. | 1295 // Run without breakpoints. |
1270 ClearBreakPoint(bp); | 1296 ClearBreakPoint(bp); |
1271 foo->Call(env->Global(), 0, NULL); | 1297 foo->Call(env->Global(), 0, NULL); |
1272 CHECK_EQ(2, break_point_hit_count); | 1298 CHECK_EQ(2, break_point_hit_count); |
1273 | 1299 |
1274 v8::Debug::SetDebugEventListener2(NULL); | 1300 v8::Debug::SetDebugEventListener2(NULL); |
1275 CheckDebuggerUnloaded(); | 1301 CheckDebuggerUnloaded(); |
1276 } | 1302 } |
1277 | 1303 |
1278 | 1304 |
1279 // Test that a break point can be set at an IC call location and survive a GC. | 1305 // Test that a break point can be set at an IC call location and survive a GC. |
1280 TEST(BreakPointICCallWithGC) { | 1306 TEST(BreakPointICCallWithGC) { |
1281 break_point_hit_count = 0; | 1307 break_point_hit_count = 0; |
1282 DebugLocalContext env; | 1308 DebugLocalContext env; |
1283 v8::HandleScope scope(env->GetIsolate()); | 1309 v8::HandleScope scope(env->GetIsolate()); |
1284 v8::Debug::SetDebugEventListener2(DebugEventBreakPointCollectGarbage); | 1310 v8::Debug::SetDebugEventListener2(DebugEventBreakPointCollectGarbage); |
1285 v8::Script::Compile(v8::String::New("function bar(){return 1;}"))->Run(); | 1311 v8::Script::Compile( |
1286 v8::Script::Compile(v8::String::New("function foo(){return bar();}"))->Run(); | 1312 v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){return 1;}")) |
1287 v8::Local<v8::Function> foo = | 1313 ->Run(); |
1288 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); | 1314 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
| 1315 "function foo(){return bar();}")) |
| 1316 ->Run(); |
| 1317 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 1318 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
1289 | 1319 |
1290 // Run without breakpoints. | 1320 // Run without breakpoints. |
1291 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); | 1321 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); |
1292 CHECK_EQ(0, break_point_hit_count); | 1322 CHECK_EQ(0, break_point_hit_count); |
1293 | 1323 |
1294 // Run with breakpoint. | 1324 // Run with breakpoint. |
1295 int bp = SetBreakPoint(foo, 0); | 1325 int bp = SetBreakPoint(foo, 0); |
1296 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); | 1326 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); |
1297 CHECK_EQ(1, break_point_hit_count); | 1327 CHECK_EQ(1, break_point_hit_count); |
1298 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); | 1328 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); |
1299 CHECK_EQ(2, break_point_hit_count); | 1329 CHECK_EQ(2, break_point_hit_count); |
1300 | 1330 |
1301 // Run without breakpoints. | 1331 // Run without breakpoints. |
1302 ClearBreakPoint(bp); | 1332 ClearBreakPoint(bp); |
1303 foo->Call(env->Global(), 0, NULL); | 1333 foo->Call(env->Global(), 0, NULL); |
1304 CHECK_EQ(2, break_point_hit_count); | 1334 CHECK_EQ(2, break_point_hit_count); |
1305 | 1335 |
1306 v8::Debug::SetDebugEventListener2(NULL); | 1336 v8::Debug::SetDebugEventListener2(NULL); |
1307 CheckDebuggerUnloaded(); | 1337 CheckDebuggerUnloaded(); |
1308 } | 1338 } |
1309 | 1339 |
1310 | 1340 |
1311 // Test that a break point can be set at an IC call location and survive a GC. | 1341 // Test that a break point can be set at an IC call location and survive a GC. |
1312 TEST(BreakPointConstructCallWithGC) { | 1342 TEST(BreakPointConstructCallWithGC) { |
1313 break_point_hit_count = 0; | 1343 break_point_hit_count = 0; |
1314 DebugLocalContext env; | 1344 DebugLocalContext env; |
1315 v8::HandleScope scope(env->GetIsolate()); | 1345 v8::HandleScope scope(env->GetIsolate()); |
1316 v8::Debug::SetDebugEventListener2(DebugEventBreakPointCollectGarbage); | 1346 v8::Debug::SetDebugEventListener2(DebugEventBreakPointCollectGarbage); |
1317 v8::Script::Compile(v8::String::New("function bar(){ this.x = 1;}"))->Run(); | 1347 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
1318 v8::Script::Compile(v8::String::New( | 1348 "function bar(){ this.x = 1;}")) |
1319 "function foo(){return new bar(1).x;}"))->Run(); | 1349 ->Run(); |
1320 v8::Local<v8::Function> foo = | 1350 v8::Script::Compile( |
1321 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); | 1351 v8::String::NewFromUtf8(env->GetIsolate(), |
| 1352 "function foo(){return new bar(1).x;}"))->Run(); |
| 1353 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 1354 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
1322 | 1355 |
1323 // Run without breakpoints. | 1356 // Run without breakpoints. |
1324 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); | 1357 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); |
1325 CHECK_EQ(0, break_point_hit_count); | 1358 CHECK_EQ(0, break_point_hit_count); |
1326 | 1359 |
1327 // Run with breakpoint. | 1360 // Run with breakpoint. |
1328 int bp = SetBreakPoint(foo, 0); | 1361 int bp = SetBreakPoint(foo, 0); |
1329 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); | 1362 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); |
1330 CHECK_EQ(1, break_point_hit_count); | 1363 CHECK_EQ(1, break_point_hit_count); |
1331 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); | 1364 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); |
(...skipping 19 matching lines...) Expand all Loading... |
1351 // a break point. | 1384 // a break point. |
1352 frame_source_line = CompileFunction(&env, | 1385 frame_source_line = CompileFunction(&env, |
1353 frame_source_line_source, | 1386 frame_source_line_source, |
1354 "frame_source_line"); | 1387 "frame_source_line"); |
1355 frame_source_column = CompileFunction(&env, | 1388 frame_source_column = CompileFunction(&env, |
1356 frame_source_column_source, | 1389 frame_source_column_source, |
1357 "frame_source_column"); | 1390 "frame_source_column"); |
1358 | 1391 |
1359 | 1392 |
1360 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 1393 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1361 v8::Script::Compile(v8::String::New("function foo(){}"))->Run(); | 1394 v8::Script::Compile( |
1362 v8::Local<v8::Function> foo = | 1395 v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){}"))->Run(); |
1363 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); | 1396 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 1397 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
1364 | 1398 |
1365 // Run without breakpoints. | 1399 // Run without breakpoints. |
1366 foo->Call(env->Global(), 0, NULL); | 1400 foo->Call(env->Global(), 0, NULL); |
1367 CHECK_EQ(0, break_point_hit_count); | 1401 CHECK_EQ(0, break_point_hit_count); |
1368 | 1402 |
1369 // Run with breakpoint | 1403 // Run with breakpoint |
1370 int bp = SetBreakPoint(foo, 0); | 1404 int bp = SetBreakPoint(foo, 0); |
1371 foo->Call(env->Global(), 0, NULL); | 1405 foo->Call(env->Global(), 0, NULL); |
1372 CHECK_EQ(1, break_point_hit_count); | 1406 CHECK_EQ(1, break_point_hit_count); |
1373 CHECK_EQ(0, last_source_line); | 1407 CHECK_EQ(0, last_source_line); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 | 1554 |
1521 | 1555 |
1522 // Test that break points can be set using the global Debug object. | 1556 // Test that break points can be set using the global Debug object. |
1523 TEST(BreakPointThroughJavaScript) { | 1557 TEST(BreakPointThroughJavaScript) { |
1524 break_point_hit_count = 0; | 1558 break_point_hit_count = 0; |
1525 DebugLocalContext env; | 1559 DebugLocalContext env; |
1526 v8::HandleScope scope(env->GetIsolate()); | 1560 v8::HandleScope scope(env->GetIsolate()); |
1527 env.ExposeDebug(); | 1561 env.ExposeDebug(); |
1528 | 1562 |
1529 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 1563 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1530 v8::Script::Compile(v8::String::New("function bar(){}"))->Run(); | 1564 v8::Script::Compile( |
1531 v8::Script::Compile(v8::String::New("function foo(){bar();bar();}"))->Run(); | 1565 v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){}"))->Run(); |
| 1566 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
| 1567 "function foo(){bar();bar();}")) |
| 1568 ->Run(); |
1532 // 012345678901234567890 | 1569 // 012345678901234567890 |
1533 // 1 2 | 1570 // 1 2 |
1534 // Break points are set at position 3 and 9 | 1571 // Break points are set at position 3 and 9 |
1535 v8::Local<v8::Script> foo = v8::Script::Compile(v8::String::New("foo()")); | 1572 v8::Local<v8::Script> foo = |
| 1573 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "foo()")); |
1536 | 1574 |
1537 // Run without breakpoints. | 1575 // Run without breakpoints. |
1538 foo->Run(); | 1576 foo->Run(); |
1539 CHECK_EQ(0, break_point_hit_count); | 1577 CHECK_EQ(0, break_point_hit_count); |
1540 | 1578 |
1541 // Run with one breakpoint | 1579 // Run with one breakpoint |
1542 int bp1 = SetBreakPointFromJS("foo", 0, 3); | 1580 int bp1 = SetBreakPointFromJS(env->GetIsolate(), "foo", 0, 3); |
1543 foo->Run(); | 1581 foo->Run(); |
1544 CHECK_EQ(1, break_point_hit_count); | 1582 CHECK_EQ(1, break_point_hit_count); |
1545 foo->Run(); | 1583 foo->Run(); |
1546 CHECK_EQ(2, break_point_hit_count); | 1584 CHECK_EQ(2, break_point_hit_count); |
1547 | 1585 |
1548 // Run with two breakpoints | 1586 // Run with two breakpoints |
1549 int bp2 = SetBreakPointFromJS("foo", 0, 9); | 1587 int bp2 = SetBreakPointFromJS(env->GetIsolate(), "foo", 0, 9); |
1550 foo->Run(); | 1588 foo->Run(); |
1551 CHECK_EQ(4, break_point_hit_count); | 1589 CHECK_EQ(4, break_point_hit_count); |
1552 foo->Run(); | 1590 foo->Run(); |
1553 CHECK_EQ(6, break_point_hit_count); | 1591 CHECK_EQ(6, break_point_hit_count); |
1554 | 1592 |
1555 // Run with one breakpoint | 1593 // Run with one breakpoint |
1556 ClearBreakPointFromJS(bp2); | 1594 ClearBreakPointFromJS(env->GetIsolate(), bp2); |
1557 foo->Run(); | 1595 foo->Run(); |
1558 CHECK_EQ(7, break_point_hit_count); | 1596 CHECK_EQ(7, break_point_hit_count); |
1559 foo->Run(); | 1597 foo->Run(); |
1560 CHECK_EQ(8, break_point_hit_count); | 1598 CHECK_EQ(8, break_point_hit_count); |
1561 | 1599 |
1562 // Run without breakpoints. | 1600 // Run without breakpoints. |
1563 ClearBreakPointFromJS(bp1); | 1601 ClearBreakPointFromJS(env->GetIsolate(), bp1); |
1564 foo->Run(); | 1602 foo->Run(); |
1565 CHECK_EQ(8, break_point_hit_count); | 1603 CHECK_EQ(8, break_point_hit_count); |
1566 | 1604 |
1567 v8::Debug::SetDebugEventListener2(NULL); | 1605 v8::Debug::SetDebugEventListener2(NULL); |
1568 CheckDebuggerUnloaded(); | 1606 CheckDebuggerUnloaded(); |
1569 | 1607 |
1570 // Make sure that the break point numbers are consecutive. | 1608 // Make sure that the break point numbers are consecutive. |
1571 CHECK_EQ(1, bp1); | 1609 CHECK_EQ(1, bp1); |
1572 CHECK_EQ(2, bp2); | 1610 CHECK_EQ(2, bp2); |
1573 } | 1611 } |
1574 | 1612 |
1575 | 1613 |
1576 // Test that break points on scripts identified by name can be set using the | 1614 // Test that break points on scripts identified by name can be set using the |
1577 // global Debug object. | 1615 // global Debug object. |
1578 TEST(ScriptBreakPointByNameThroughJavaScript) { | 1616 TEST(ScriptBreakPointByNameThroughJavaScript) { |
1579 break_point_hit_count = 0; | 1617 break_point_hit_count = 0; |
1580 DebugLocalContext env; | 1618 DebugLocalContext env; |
1581 v8::HandleScope scope(env->GetIsolate()); | 1619 v8::HandleScope scope(env->GetIsolate()); |
1582 env.ExposeDebug(); | 1620 env.ExposeDebug(); |
1583 | 1621 |
1584 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 1622 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1585 | 1623 |
1586 v8::Local<v8::String> script = v8::String::New( | 1624 v8::Local<v8::String> script = v8::String::NewFromUtf8( |
| 1625 env->GetIsolate(), |
1587 "function f() {\n" | 1626 "function f() {\n" |
1588 " function h() {\n" | 1627 " function h() {\n" |
1589 " a = 0; // line 2\n" | 1628 " a = 0; // line 2\n" |
1590 " }\n" | 1629 " }\n" |
1591 " b = 1; // line 4\n" | 1630 " b = 1; // line 4\n" |
1592 " return h();\n" | 1631 " return h();\n" |
1593 "}\n" | 1632 "}\n" |
1594 "\n" | 1633 "\n" |
1595 "function g() {\n" | 1634 "function g() {\n" |
1596 " function h() {\n" | 1635 " function h() {\n" |
1597 " a = 0;\n" | 1636 " a = 0;\n" |
1598 " }\n" | 1637 " }\n" |
1599 " b = 2; // line 12\n" | 1638 " b = 2; // line 12\n" |
1600 " h();\n" | 1639 " h();\n" |
1601 " b = 3; // line 14\n" | 1640 " b = 3; // line 14\n" |
1602 " f(); // line 15\n" | 1641 " f(); // line 15\n" |
1603 "}"); | 1642 "}"); |
1604 | 1643 |
1605 // Compile the script and get the two functions. | 1644 // Compile the script and get the two functions. |
1606 v8::ScriptOrigin origin = | 1645 v8::ScriptOrigin origin = |
1607 v8::ScriptOrigin(v8::String::New("test")); | 1646 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
1608 v8::Script::Compile(script, &origin)->Run(); | 1647 v8::Script::Compile(script, &origin)->Run(); |
1609 v8::Local<v8::Function> f = | 1648 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
1610 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 1649 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
1611 v8::Local<v8::Function> g = | 1650 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
1612 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g"))); | 1651 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
1613 | 1652 |
1614 // Call f and g without break points. | 1653 // Call f and g without break points. |
1615 break_point_hit_count = 0; | 1654 break_point_hit_count = 0; |
1616 f->Call(env->Global(), 0, NULL); | 1655 f->Call(env->Global(), 0, NULL); |
1617 CHECK_EQ(0, break_point_hit_count); | 1656 CHECK_EQ(0, break_point_hit_count); |
1618 g->Call(env->Global(), 0, NULL); | 1657 g->Call(env->Global(), 0, NULL); |
1619 CHECK_EQ(0, break_point_hit_count); | 1658 CHECK_EQ(0, break_point_hit_count); |
1620 | 1659 |
1621 // Call f and g with break point on line 12. | 1660 // Call f and g with break point on line 12. |
1622 int sbp1 = SetScriptBreakPointByNameFromJS("test", 12, 0); | 1661 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 12, 0); |
1623 break_point_hit_count = 0; | 1662 break_point_hit_count = 0; |
1624 f->Call(env->Global(), 0, NULL); | 1663 f->Call(env->Global(), 0, NULL); |
1625 CHECK_EQ(0, break_point_hit_count); | 1664 CHECK_EQ(0, break_point_hit_count); |
1626 g->Call(env->Global(), 0, NULL); | 1665 g->Call(env->Global(), 0, NULL); |
1627 CHECK_EQ(1, break_point_hit_count); | 1666 CHECK_EQ(1, break_point_hit_count); |
1628 | 1667 |
1629 // Remove the break point again. | 1668 // Remove the break point again. |
1630 break_point_hit_count = 0; | 1669 break_point_hit_count = 0; |
1631 ClearBreakPointFromJS(sbp1); | 1670 ClearBreakPointFromJS(env->GetIsolate(), sbp1); |
1632 f->Call(env->Global(), 0, NULL); | 1671 f->Call(env->Global(), 0, NULL); |
1633 CHECK_EQ(0, break_point_hit_count); | 1672 CHECK_EQ(0, break_point_hit_count); |
1634 g->Call(env->Global(), 0, NULL); | 1673 g->Call(env->Global(), 0, NULL); |
1635 CHECK_EQ(0, break_point_hit_count); | 1674 CHECK_EQ(0, break_point_hit_count); |
1636 | 1675 |
1637 // Call f and g with break point on line 2. | 1676 // Call f and g with break point on line 2. |
1638 int sbp2 = SetScriptBreakPointByNameFromJS("test", 2, 0); | 1677 int sbp2 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 2, 0); |
1639 break_point_hit_count = 0; | 1678 break_point_hit_count = 0; |
1640 f->Call(env->Global(), 0, NULL); | 1679 f->Call(env->Global(), 0, NULL); |
1641 CHECK_EQ(1, break_point_hit_count); | 1680 CHECK_EQ(1, break_point_hit_count); |
1642 g->Call(env->Global(), 0, NULL); | 1681 g->Call(env->Global(), 0, NULL); |
1643 CHECK_EQ(2, break_point_hit_count); | 1682 CHECK_EQ(2, break_point_hit_count); |
1644 | 1683 |
1645 // Call f and g with break point on line 2, 4, 12, 14 and 15. | 1684 // Call f and g with break point on line 2, 4, 12, 14 and 15. |
1646 int sbp3 = SetScriptBreakPointByNameFromJS("test", 4, 0); | 1685 int sbp3 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 4, 0); |
1647 int sbp4 = SetScriptBreakPointByNameFromJS("test", 12, 0); | 1686 int sbp4 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 12, 0); |
1648 int sbp5 = SetScriptBreakPointByNameFromJS("test", 14, 0); | 1687 int sbp5 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 14, 0); |
1649 int sbp6 = SetScriptBreakPointByNameFromJS("test", 15, 0); | 1688 int sbp6 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 15, 0); |
1650 break_point_hit_count = 0; | 1689 break_point_hit_count = 0; |
1651 f->Call(env->Global(), 0, NULL); | 1690 f->Call(env->Global(), 0, NULL); |
1652 CHECK_EQ(2, break_point_hit_count); | 1691 CHECK_EQ(2, break_point_hit_count); |
1653 g->Call(env->Global(), 0, NULL); | 1692 g->Call(env->Global(), 0, NULL); |
1654 CHECK_EQ(7, break_point_hit_count); | 1693 CHECK_EQ(7, break_point_hit_count); |
1655 | 1694 |
1656 // Remove all the break points again. | 1695 // Remove all the break points again. |
1657 break_point_hit_count = 0; | 1696 break_point_hit_count = 0; |
1658 ClearBreakPointFromJS(sbp2); | 1697 ClearBreakPointFromJS(env->GetIsolate(), sbp2); |
1659 ClearBreakPointFromJS(sbp3); | 1698 ClearBreakPointFromJS(env->GetIsolate(), sbp3); |
1660 ClearBreakPointFromJS(sbp4); | 1699 ClearBreakPointFromJS(env->GetIsolate(), sbp4); |
1661 ClearBreakPointFromJS(sbp5); | 1700 ClearBreakPointFromJS(env->GetIsolate(), sbp5); |
1662 ClearBreakPointFromJS(sbp6); | 1701 ClearBreakPointFromJS(env->GetIsolate(), sbp6); |
1663 f->Call(env->Global(), 0, NULL); | 1702 f->Call(env->Global(), 0, NULL); |
1664 CHECK_EQ(0, break_point_hit_count); | 1703 CHECK_EQ(0, break_point_hit_count); |
1665 g->Call(env->Global(), 0, NULL); | 1704 g->Call(env->Global(), 0, NULL); |
1666 CHECK_EQ(0, break_point_hit_count); | 1705 CHECK_EQ(0, break_point_hit_count); |
1667 | 1706 |
1668 v8::Debug::SetDebugEventListener2(NULL); | 1707 v8::Debug::SetDebugEventListener2(NULL); |
1669 CheckDebuggerUnloaded(); | 1708 CheckDebuggerUnloaded(); |
1670 | 1709 |
1671 // Make sure that the break point numbers are consecutive. | 1710 // Make sure that the break point numbers are consecutive. |
1672 CHECK_EQ(1, sbp1); | 1711 CHECK_EQ(1, sbp1); |
1673 CHECK_EQ(2, sbp2); | 1712 CHECK_EQ(2, sbp2); |
1674 CHECK_EQ(3, sbp3); | 1713 CHECK_EQ(3, sbp3); |
1675 CHECK_EQ(4, sbp4); | 1714 CHECK_EQ(4, sbp4); |
1676 CHECK_EQ(5, sbp5); | 1715 CHECK_EQ(5, sbp5); |
1677 CHECK_EQ(6, sbp6); | 1716 CHECK_EQ(6, sbp6); |
1678 } | 1717 } |
1679 | 1718 |
1680 | 1719 |
1681 TEST(ScriptBreakPointByIdThroughJavaScript) { | 1720 TEST(ScriptBreakPointByIdThroughJavaScript) { |
1682 break_point_hit_count = 0; | 1721 break_point_hit_count = 0; |
1683 DebugLocalContext env; | 1722 DebugLocalContext env; |
1684 v8::HandleScope scope(env->GetIsolate()); | 1723 v8::HandleScope scope(env->GetIsolate()); |
1685 env.ExposeDebug(); | 1724 env.ExposeDebug(); |
1686 | 1725 |
1687 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 1726 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1688 | 1727 |
1689 v8::Local<v8::String> source = v8::String::New( | 1728 v8::Local<v8::String> source = v8::String::NewFromUtf8( |
| 1729 env->GetIsolate(), |
1690 "function f() {\n" | 1730 "function f() {\n" |
1691 " function h() {\n" | 1731 " function h() {\n" |
1692 " a = 0; // line 2\n" | 1732 " a = 0; // line 2\n" |
1693 " }\n" | 1733 " }\n" |
1694 " b = 1; // line 4\n" | 1734 " b = 1; // line 4\n" |
1695 " return h();\n" | 1735 " return h();\n" |
1696 "}\n" | 1736 "}\n" |
1697 "\n" | 1737 "\n" |
1698 "function g() {\n" | 1738 "function g() {\n" |
1699 " function h() {\n" | 1739 " function h() {\n" |
1700 " a = 0;\n" | 1740 " a = 0;\n" |
1701 " }\n" | 1741 " }\n" |
1702 " b = 2; // line 12\n" | 1742 " b = 2; // line 12\n" |
1703 " h();\n" | 1743 " h();\n" |
1704 " b = 3; // line 14\n" | 1744 " b = 3; // line 14\n" |
1705 " f(); // line 15\n" | 1745 " f(); // line 15\n" |
1706 "}"); | 1746 "}"); |
1707 | 1747 |
1708 // Compile the script and get the two functions. | 1748 // Compile the script and get the two functions. |
1709 v8::ScriptOrigin origin = | 1749 v8::ScriptOrigin origin = |
1710 v8::ScriptOrigin(v8::String::New("test")); | 1750 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
1711 v8::Local<v8::Script> script = v8::Script::Compile(source, &origin); | 1751 v8::Local<v8::Script> script = v8::Script::Compile(source, &origin); |
1712 script->Run(); | 1752 script->Run(); |
1713 v8::Local<v8::Function> f = | 1753 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
1714 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 1754 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
1715 v8::Local<v8::Function> g = | 1755 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
1716 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g"))); | 1756 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
1717 | 1757 |
1718 // Get the script id knowing that internally it is a 32 integer. | 1758 // Get the script id knowing that internally it is a 32 integer. |
1719 uint32_t script_id = script->Id()->Uint32Value(); | 1759 int script_id = script->GetId(); |
1720 | 1760 |
1721 // Call f and g without break points. | 1761 // Call f and g without break points. |
1722 break_point_hit_count = 0; | 1762 break_point_hit_count = 0; |
1723 f->Call(env->Global(), 0, NULL); | 1763 f->Call(env->Global(), 0, NULL); |
1724 CHECK_EQ(0, break_point_hit_count); | 1764 CHECK_EQ(0, break_point_hit_count); |
1725 g->Call(env->Global(), 0, NULL); | 1765 g->Call(env->Global(), 0, NULL); |
1726 CHECK_EQ(0, break_point_hit_count); | 1766 CHECK_EQ(0, break_point_hit_count); |
1727 | 1767 |
1728 // Call f and g with break point on line 12. | 1768 // Call f and g with break point on line 12. |
1729 int sbp1 = SetScriptBreakPointByIdFromJS(script_id, 12, 0); | 1769 int sbp1 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 12, 0); |
1730 break_point_hit_count = 0; | 1770 break_point_hit_count = 0; |
1731 f->Call(env->Global(), 0, NULL); | 1771 f->Call(env->Global(), 0, NULL); |
1732 CHECK_EQ(0, break_point_hit_count); | 1772 CHECK_EQ(0, break_point_hit_count); |
1733 g->Call(env->Global(), 0, NULL); | 1773 g->Call(env->Global(), 0, NULL); |
1734 CHECK_EQ(1, break_point_hit_count); | 1774 CHECK_EQ(1, break_point_hit_count); |
1735 | 1775 |
1736 // Remove the break point again. | 1776 // Remove the break point again. |
1737 break_point_hit_count = 0; | 1777 break_point_hit_count = 0; |
1738 ClearBreakPointFromJS(sbp1); | 1778 ClearBreakPointFromJS(env->GetIsolate(), sbp1); |
1739 f->Call(env->Global(), 0, NULL); | 1779 f->Call(env->Global(), 0, NULL); |
1740 CHECK_EQ(0, break_point_hit_count); | 1780 CHECK_EQ(0, break_point_hit_count); |
1741 g->Call(env->Global(), 0, NULL); | 1781 g->Call(env->Global(), 0, NULL); |
1742 CHECK_EQ(0, break_point_hit_count); | 1782 CHECK_EQ(0, break_point_hit_count); |
1743 | 1783 |
1744 // Call f and g with break point on line 2. | 1784 // Call f and g with break point on line 2. |
1745 int sbp2 = SetScriptBreakPointByIdFromJS(script_id, 2, 0); | 1785 int sbp2 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 2, 0); |
1746 break_point_hit_count = 0; | 1786 break_point_hit_count = 0; |
1747 f->Call(env->Global(), 0, NULL); | 1787 f->Call(env->Global(), 0, NULL); |
1748 CHECK_EQ(1, break_point_hit_count); | 1788 CHECK_EQ(1, break_point_hit_count); |
1749 g->Call(env->Global(), 0, NULL); | 1789 g->Call(env->Global(), 0, NULL); |
1750 CHECK_EQ(2, break_point_hit_count); | 1790 CHECK_EQ(2, break_point_hit_count); |
1751 | 1791 |
1752 // Call f and g with break point on line 2, 4, 12, 14 and 15. | 1792 // Call f and g with break point on line 2, 4, 12, 14 and 15. |
1753 int sbp3 = SetScriptBreakPointByIdFromJS(script_id, 4, 0); | 1793 int sbp3 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 4, 0); |
1754 int sbp4 = SetScriptBreakPointByIdFromJS(script_id, 12, 0); | 1794 int sbp4 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 12, 0); |
1755 int sbp5 = SetScriptBreakPointByIdFromJS(script_id, 14, 0); | 1795 int sbp5 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 14, 0); |
1756 int sbp6 = SetScriptBreakPointByIdFromJS(script_id, 15, 0); | 1796 int sbp6 = SetScriptBreakPointByIdFromJS(env->GetIsolate(), script_id, 15, 0); |
1757 break_point_hit_count = 0; | 1797 break_point_hit_count = 0; |
1758 f->Call(env->Global(), 0, NULL); | 1798 f->Call(env->Global(), 0, NULL); |
1759 CHECK_EQ(2, break_point_hit_count); | 1799 CHECK_EQ(2, break_point_hit_count); |
1760 g->Call(env->Global(), 0, NULL); | 1800 g->Call(env->Global(), 0, NULL); |
1761 CHECK_EQ(7, break_point_hit_count); | 1801 CHECK_EQ(7, break_point_hit_count); |
1762 | 1802 |
1763 // Remove all the break points again. | 1803 // Remove all the break points again. |
1764 break_point_hit_count = 0; | 1804 break_point_hit_count = 0; |
1765 ClearBreakPointFromJS(sbp2); | 1805 ClearBreakPointFromJS(env->GetIsolate(), sbp2); |
1766 ClearBreakPointFromJS(sbp3); | 1806 ClearBreakPointFromJS(env->GetIsolate(), sbp3); |
1767 ClearBreakPointFromJS(sbp4); | 1807 ClearBreakPointFromJS(env->GetIsolate(), sbp4); |
1768 ClearBreakPointFromJS(sbp5); | 1808 ClearBreakPointFromJS(env->GetIsolate(), sbp5); |
1769 ClearBreakPointFromJS(sbp6); | 1809 ClearBreakPointFromJS(env->GetIsolate(), sbp6); |
1770 f->Call(env->Global(), 0, NULL); | 1810 f->Call(env->Global(), 0, NULL); |
1771 CHECK_EQ(0, break_point_hit_count); | 1811 CHECK_EQ(0, break_point_hit_count); |
1772 g->Call(env->Global(), 0, NULL); | 1812 g->Call(env->Global(), 0, NULL); |
1773 CHECK_EQ(0, break_point_hit_count); | 1813 CHECK_EQ(0, break_point_hit_count); |
1774 | 1814 |
1775 v8::Debug::SetDebugEventListener2(NULL); | 1815 v8::Debug::SetDebugEventListener2(NULL); |
1776 CheckDebuggerUnloaded(); | 1816 CheckDebuggerUnloaded(); |
1777 | 1817 |
1778 // Make sure that the break point numbers are consecutive. | 1818 // Make sure that the break point numbers are consecutive. |
1779 CHECK_EQ(1, sbp1); | 1819 CHECK_EQ(1, sbp1); |
1780 CHECK_EQ(2, sbp2); | 1820 CHECK_EQ(2, sbp2); |
1781 CHECK_EQ(3, sbp3); | 1821 CHECK_EQ(3, sbp3); |
1782 CHECK_EQ(4, sbp4); | 1822 CHECK_EQ(4, sbp4); |
1783 CHECK_EQ(5, sbp5); | 1823 CHECK_EQ(5, sbp5); |
1784 CHECK_EQ(6, sbp6); | 1824 CHECK_EQ(6, sbp6); |
1785 } | 1825 } |
1786 | 1826 |
1787 | 1827 |
1788 // Test conditional script break points. | 1828 // Test conditional script break points. |
1789 TEST(EnableDisableScriptBreakPoint) { | 1829 TEST(EnableDisableScriptBreakPoint) { |
1790 break_point_hit_count = 0; | 1830 break_point_hit_count = 0; |
1791 DebugLocalContext env; | 1831 DebugLocalContext env; |
1792 v8::HandleScope scope(env->GetIsolate()); | 1832 v8::HandleScope scope(env->GetIsolate()); |
1793 env.ExposeDebug(); | 1833 env.ExposeDebug(); |
1794 | 1834 |
1795 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 1835 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1796 | 1836 |
1797 v8::Local<v8::String> script = v8::String::New( | 1837 v8::Local<v8::String> script = v8::String::NewFromUtf8( |
| 1838 env->GetIsolate(), |
1798 "function f() {\n" | 1839 "function f() {\n" |
1799 " a = 0; // line 1\n" | 1840 " a = 0; // line 1\n" |
1800 "};"); | 1841 "};"); |
1801 | 1842 |
1802 // Compile the script and get function f. | 1843 // Compile the script and get function f. |
1803 v8::ScriptOrigin origin = | 1844 v8::ScriptOrigin origin = |
1804 v8::ScriptOrigin(v8::String::New("test")); | 1845 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
1805 v8::Script::Compile(script, &origin)->Run(); | 1846 v8::Script::Compile(script, &origin)->Run(); |
1806 v8::Local<v8::Function> f = | 1847 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
1807 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 1848 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
1808 | 1849 |
1809 // Set script break point on line 1 (in function f). | 1850 // Set script break point on line 1 (in function f). |
1810 int sbp = SetScriptBreakPointByNameFromJS("test", 1, 0); | 1851 int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); |
1811 | 1852 |
1812 // Call f while enabeling and disabling the script break point. | 1853 // Call f while enabeling and disabling the script break point. |
1813 break_point_hit_count = 0; | 1854 break_point_hit_count = 0; |
1814 f->Call(env->Global(), 0, NULL); | 1855 f->Call(env->Global(), 0, NULL); |
1815 CHECK_EQ(1, break_point_hit_count); | 1856 CHECK_EQ(1, break_point_hit_count); |
1816 | 1857 |
1817 DisableScriptBreakPointFromJS(sbp); | 1858 DisableScriptBreakPointFromJS(env->GetIsolate(), sbp); |
1818 f->Call(env->Global(), 0, NULL); | 1859 f->Call(env->Global(), 0, NULL); |
1819 CHECK_EQ(1, break_point_hit_count); | 1860 CHECK_EQ(1, break_point_hit_count); |
1820 | 1861 |
1821 EnableScriptBreakPointFromJS(sbp); | 1862 EnableScriptBreakPointFromJS(env->GetIsolate(), sbp); |
1822 f->Call(env->Global(), 0, NULL); | 1863 f->Call(env->Global(), 0, NULL); |
1823 CHECK_EQ(2, break_point_hit_count); | 1864 CHECK_EQ(2, break_point_hit_count); |
1824 | 1865 |
1825 DisableScriptBreakPointFromJS(sbp); | 1866 DisableScriptBreakPointFromJS(env->GetIsolate(), sbp); |
1826 f->Call(env->Global(), 0, NULL); | 1867 f->Call(env->Global(), 0, NULL); |
1827 CHECK_EQ(2, break_point_hit_count); | 1868 CHECK_EQ(2, break_point_hit_count); |
1828 | 1869 |
1829 // Reload the script and get f again checking that the disabeling survives. | 1870 // Reload the script and get f again checking that the disabeling survives. |
1830 v8::Script::Compile(script, &origin)->Run(); | 1871 v8::Script::Compile(script, &origin)->Run(); |
1831 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 1872 f = v8::Local<v8::Function>::Cast( |
| 1873 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
1832 f->Call(env->Global(), 0, NULL); | 1874 f->Call(env->Global(), 0, NULL); |
1833 CHECK_EQ(2, break_point_hit_count); | 1875 CHECK_EQ(2, break_point_hit_count); |
1834 | 1876 |
1835 EnableScriptBreakPointFromJS(sbp); | 1877 EnableScriptBreakPointFromJS(env->GetIsolate(), sbp); |
1836 f->Call(env->Global(), 0, NULL); | 1878 f->Call(env->Global(), 0, NULL); |
1837 CHECK_EQ(3, break_point_hit_count); | 1879 CHECK_EQ(3, break_point_hit_count); |
1838 | 1880 |
1839 v8::Debug::SetDebugEventListener2(NULL); | 1881 v8::Debug::SetDebugEventListener2(NULL); |
1840 CheckDebuggerUnloaded(); | 1882 CheckDebuggerUnloaded(); |
1841 } | 1883 } |
1842 | 1884 |
1843 | 1885 |
1844 // Test conditional script break points. | 1886 // Test conditional script break points. |
1845 TEST(ConditionalScriptBreakPoint) { | 1887 TEST(ConditionalScriptBreakPoint) { |
1846 break_point_hit_count = 0; | 1888 break_point_hit_count = 0; |
1847 DebugLocalContext env; | 1889 DebugLocalContext env; |
1848 v8::HandleScope scope(env->GetIsolate()); | 1890 v8::HandleScope scope(env->GetIsolate()); |
1849 env.ExposeDebug(); | 1891 env.ExposeDebug(); |
1850 | 1892 |
1851 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 1893 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1852 | 1894 |
1853 v8::Local<v8::String> script = v8::String::New( | 1895 v8::Local<v8::String> script = v8::String::NewFromUtf8( |
| 1896 env->GetIsolate(), |
1854 "count = 0;\n" | 1897 "count = 0;\n" |
1855 "function f() {\n" | 1898 "function f() {\n" |
1856 " g(count++); // line 2\n" | 1899 " g(count++); // line 2\n" |
1857 "};\n" | 1900 "};\n" |
1858 "function g(x) {\n" | 1901 "function g(x) {\n" |
1859 " var a=x; // line 5\n" | 1902 " var a=x; // line 5\n" |
1860 "};"); | 1903 "};"); |
1861 | 1904 |
1862 // Compile the script and get function f. | 1905 // Compile the script and get function f. |
1863 v8::ScriptOrigin origin = | 1906 v8::ScriptOrigin origin = |
1864 v8::ScriptOrigin(v8::String::New("test")); | 1907 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
1865 v8::Script::Compile(script, &origin)->Run(); | 1908 v8::Script::Compile(script, &origin)->Run(); |
1866 v8::Local<v8::Function> f = | 1909 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
1867 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 1910 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
1868 | 1911 |
1869 // Set script break point on line 5 (in function g). | 1912 // Set script break point on line 5 (in function g). |
1870 int sbp1 = SetScriptBreakPointByNameFromJS("test", 5, 0); | 1913 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 5, 0); |
1871 | 1914 |
1872 // Call f with different conditions on the script break point. | 1915 // Call f with different conditions on the script break point. |
1873 break_point_hit_count = 0; | 1916 break_point_hit_count = 0; |
1874 ChangeScriptBreakPointConditionFromJS(sbp1, "false"); | 1917 ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "false"); |
1875 f->Call(env->Global(), 0, NULL); | 1918 f->Call(env->Global(), 0, NULL); |
1876 CHECK_EQ(0, break_point_hit_count); | 1919 CHECK_EQ(0, break_point_hit_count); |
1877 | 1920 |
1878 ChangeScriptBreakPointConditionFromJS(sbp1, "true"); | 1921 ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "true"); |
1879 break_point_hit_count = 0; | 1922 break_point_hit_count = 0; |
1880 f->Call(env->Global(), 0, NULL); | 1923 f->Call(env->Global(), 0, NULL); |
1881 CHECK_EQ(1, break_point_hit_count); | 1924 CHECK_EQ(1, break_point_hit_count); |
1882 | 1925 |
1883 ChangeScriptBreakPointConditionFromJS(sbp1, "x % 2 == 0"); | 1926 ChangeScriptBreakPointConditionFromJS(env->GetIsolate(), sbp1, "x % 2 == 0"); |
1884 break_point_hit_count = 0; | 1927 break_point_hit_count = 0; |
1885 for (int i = 0; i < 10; i++) { | 1928 for (int i = 0; i < 10; i++) { |
1886 f->Call(env->Global(), 0, NULL); | 1929 f->Call(env->Global(), 0, NULL); |
1887 } | 1930 } |
1888 CHECK_EQ(5, break_point_hit_count); | 1931 CHECK_EQ(5, break_point_hit_count); |
1889 | 1932 |
1890 // Reload the script and get f again checking that the condition survives. | 1933 // Reload the script and get f again checking that the condition survives. |
1891 v8::Script::Compile(script, &origin)->Run(); | 1934 v8::Script::Compile(script, &origin)->Run(); |
1892 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 1935 f = v8::Local<v8::Function>::Cast( |
| 1936 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
1893 | 1937 |
1894 break_point_hit_count = 0; | 1938 break_point_hit_count = 0; |
1895 for (int i = 0; i < 10; i++) { | 1939 for (int i = 0; i < 10; i++) { |
1896 f->Call(env->Global(), 0, NULL); | 1940 f->Call(env->Global(), 0, NULL); |
1897 } | 1941 } |
1898 CHECK_EQ(5, break_point_hit_count); | 1942 CHECK_EQ(5, break_point_hit_count); |
1899 | 1943 |
1900 v8::Debug::SetDebugEventListener2(NULL); | 1944 v8::Debug::SetDebugEventListener2(NULL); |
1901 CheckDebuggerUnloaded(); | 1945 CheckDebuggerUnloaded(); |
1902 } | 1946 } |
1903 | 1947 |
1904 | 1948 |
1905 // Test ignore count on script break points. | 1949 // Test ignore count on script break points. |
1906 TEST(ScriptBreakPointIgnoreCount) { | 1950 TEST(ScriptBreakPointIgnoreCount) { |
1907 break_point_hit_count = 0; | 1951 break_point_hit_count = 0; |
1908 DebugLocalContext env; | 1952 DebugLocalContext env; |
1909 v8::HandleScope scope(env->GetIsolate()); | 1953 v8::HandleScope scope(env->GetIsolate()); |
1910 env.ExposeDebug(); | 1954 env.ExposeDebug(); |
1911 | 1955 |
1912 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 1956 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1913 | 1957 |
1914 v8::Local<v8::String> script = v8::String::New( | 1958 v8::Local<v8::String> script = v8::String::NewFromUtf8( |
| 1959 env->GetIsolate(), |
1915 "function f() {\n" | 1960 "function f() {\n" |
1916 " a = 0; // line 1\n" | 1961 " a = 0; // line 1\n" |
1917 "};"); | 1962 "};"); |
1918 | 1963 |
1919 // Compile the script and get function f. | 1964 // Compile the script and get function f. |
1920 v8::ScriptOrigin origin = | 1965 v8::ScriptOrigin origin = |
1921 v8::ScriptOrigin(v8::String::New("test")); | 1966 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
1922 v8::Script::Compile(script, &origin)->Run(); | 1967 v8::Script::Compile(script, &origin)->Run(); |
1923 v8::Local<v8::Function> f = | 1968 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
1924 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 1969 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
1925 | 1970 |
1926 // Set script break point on line 1 (in function f). | 1971 // Set script break point on line 1 (in function f). |
1927 int sbp = SetScriptBreakPointByNameFromJS("test", 1, 0); | 1972 int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); |
1928 | 1973 |
1929 // Call f with different ignores on the script break point. | 1974 // Call f with different ignores on the script break point. |
1930 break_point_hit_count = 0; | 1975 break_point_hit_count = 0; |
1931 ChangeScriptBreakPointIgnoreCountFromJS(sbp, 1); | 1976 ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 1); |
1932 f->Call(env->Global(), 0, NULL); | 1977 f->Call(env->Global(), 0, NULL); |
1933 CHECK_EQ(0, break_point_hit_count); | 1978 CHECK_EQ(0, break_point_hit_count); |
1934 f->Call(env->Global(), 0, NULL); | 1979 f->Call(env->Global(), 0, NULL); |
1935 CHECK_EQ(1, break_point_hit_count); | 1980 CHECK_EQ(1, break_point_hit_count); |
1936 | 1981 |
1937 ChangeScriptBreakPointIgnoreCountFromJS(sbp, 5); | 1982 ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 5); |
1938 break_point_hit_count = 0; | 1983 break_point_hit_count = 0; |
1939 for (int i = 0; i < 10; i++) { | 1984 for (int i = 0; i < 10; i++) { |
1940 f->Call(env->Global(), 0, NULL); | 1985 f->Call(env->Global(), 0, NULL); |
1941 } | 1986 } |
1942 CHECK_EQ(5, break_point_hit_count); | 1987 CHECK_EQ(5, break_point_hit_count); |
1943 | 1988 |
1944 // Reload the script and get f again checking that the ignore survives. | 1989 // Reload the script and get f again checking that the ignore survives. |
1945 v8::Script::Compile(script, &origin)->Run(); | 1990 v8::Script::Compile(script, &origin)->Run(); |
1946 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 1991 f = v8::Local<v8::Function>::Cast( |
| 1992 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
1947 | 1993 |
1948 break_point_hit_count = 0; | 1994 break_point_hit_count = 0; |
1949 for (int i = 0; i < 10; i++) { | 1995 for (int i = 0; i < 10; i++) { |
1950 f->Call(env->Global(), 0, NULL); | 1996 f->Call(env->Global(), 0, NULL); |
1951 } | 1997 } |
1952 CHECK_EQ(5, break_point_hit_count); | 1998 CHECK_EQ(5, break_point_hit_count); |
1953 | 1999 |
1954 v8::Debug::SetDebugEventListener2(NULL); | 2000 v8::Debug::SetDebugEventListener2(NULL); |
1955 CheckDebuggerUnloaded(); | 2001 CheckDebuggerUnloaded(); |
1956 } | 2002 } |
1957 | 2003 |
1958 | 2004 |
1959 // Test that script break points survive when a script is reloaded. | 2005 // Test that script break points survive when a script is reloaded. |
1960 TEST(ScriptBreakPointReload) { | 2006 TEST(ScriptBreakPointReload) { |
1961 break_point_hit_count = 0; | 2007 break_point_hit_count = 0; |
1962 DebugLocalContext env; | 2008 DebugLocalContext env; |
1963 v8::HandleScope scope(env->GetIsolate()); | 2009 v8::HandleScope scope(env->GetIsolate()); |
1964 env.ExposeDebug(); | 2010 env.ExposeDebug(); |
1965 | 2011 |
1966 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 2012 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
1967 | 2013 |
1968 v8::Local<v8::Function> f; | 2014 v8::Local<v8::Function> f; |
1969 v8::Local<v8::String> script = v8::String::New( | 2015 v8::Local<v8::String> script = v8::String::NewFromUtf8( |
| 2016 env->GetIsolate(), |
1970 "function f() {\n" | 2017 "function f() {\n" |
1971 " function h() {\n" | 2018 " function h() {\n" |
1972 " a = 0; // line 2\n" | 2019 " a = 0; // line 2\n" |
1973 " }\n" | 2020 " }\n" |
1974 " b = 1; // line 4\n" | 2021 " b = 1; // line 4\n" |
1975 " return h();\n" | 2022 " return h();\n" |
1976 "}"); | 2023 "}"); |
1977 | 2024 |
1978 v8::ScriptOrigin origin_1 = v8::ScriptOrigin(v8::String::New("1")); | 2025 v8::ScriptOrigin origin_1 = |
1979 v8::ScriptOrigin origin_2 = v8::ScriptOrigin(v8::String::New("2")); | 2026 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "1")); |
| 2027 v8::ScriptOrigin origin_2 = |
| 2028 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "2")); |
1980 | 2029 |
1981 // Set a script break point before the script is loaded. | 2030 // Set a script break point before the script is loaded. |
1982 SetScriptBreakPointByNameFromJS("1", 2, 0); | 2031 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "1", 2, 0); |
1983 | 2032 |
1984 // Compile the script and get the function. | 2033 // Compile the script and get the function. |
1985 v8::Script::Compile(script, &origin_1)->Run(); | 2034 v8::Script::Compile(script, &origin_1)->Run(); |
1986 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 2035 f = v8::Local<v8::Function>::Cast( |
| 2036 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
1987 | 2037 |
1988 // Call f and check that the script break point is active. | 2038 // Call f and check that the script break point is active. |
1989 break_point_hit_count = 0; | 2039 break_point_hit_count = 0; |
1990 f->Call(env->Global(), 0, NULL); | 2040 f->Call(env->Global(), 0, NULL); |
1991 CHECK_EQ(1, break_point_hit_count); | 2041 CHECK_EQ(1, break_point_hit_count); |
1992 | 2042 |
1993 // Compile the script again with a different script data and get the | 2043 // Compile the script again with a different script data and get the |
1994 // function. | 2044 // function. |
1995 v8::Script::Compile(script, &origin_2)->Run(); | 2045 v8::Script::Compile(script, &origin_2)->Run(); |
1996 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 2046 f = v8::Local<v8::Function>::Cast( |
| 2047 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
1997 | 2048 |
1998 // Call f and check that no break points are set. | 2049 // Call f and check that no break points are set. |
1999 break_point_hit_count = 0; | 2050 break_point_hit_count = 0; |
2000 f->Call(env->Global(), 0, NULL); | 2051 f->Call(env->Global(), 0, NULL); |
2001 CHECK_EQ(0, break_point_hit_count); | 2052 CHECK_EQ(0, break_point_hit_count); |
2002 | 2053 |
2003 // Compile the script again and get the function. | 2054 // Compile the script again and get the function. |
2004 v8::Script::Compile(script, &origin_1)->Run(); | 2055 v8::Script::Compile(script, &origin_1)->Run(); |
2005 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 2056 f = v8::Local<v8::Function>::Cast( |
| 2057 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
2006 | 2058 |
2007 // Call f and check that the script break point is active. | 2059 // Call f and check that the script break point is active. |
2008 break_point_hit_count = 0; | 2060 break_point_hit_count = 0; |
2009 f->Call(env->Global(), 0, NULL); | 2061 f->Call(env->Global(), 0, NULL); |
2010 CHECK_EQ(1, break_point_hit_count); | 2062 CHECK_EQ(1, break_point_hit_count); |
2011 | 2063 |
2012 v8::Debug::SetDebugEventListener2(NULL); | 2064 v8::Debug::SetDebugEventListener2(NULL); |
2013 CheckDebuggerUnloaded(); | 2065 CheckDebuggerUnloaded(); |
2014 } | 2066 } |
2015 | 2067 |
2016 | 2068 |
2017 // Test when several scripts has the same script data | 2069 // Test when several scripts has the same script data |
2018 TEST(ScriptBreakPointMultiple) { | 2070 TEST(ScriptBreakPointMultiple) { |
2019 break_point_hit_count = 0; | 2071 break_point_hit_count = 0; |
2020 DebugLocalContext env; | 2072 DebugLocalContext env; |
2021 v8::HandleScope scope(env->GetIsolate()); | 2073 v8::HandleScope scope(env->GetIsolate()); |
2022 env.ExposeDebug(); | 2074 env.ExposeDebug(); |
2023 | 2075 |
2024 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 2076 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
2025 | 2077 |
2026 v8::Local<v8::Function> f; | 2078 v8::Local<v8::Function> f; |
2027 v8::Local<v8::String> script_f = v8::String::New( | 2079 v8::Local<v8::String> script_f = |
2028 "function f() {\n" | 2080 v8::String::NewFromUtf8(env->GetIsolate(), |
2029 " a = 0; // line 1\n" | 2081 "function f() {\n" |
2030 "}"); | 2082 " a = 0; // line 1\n" |
| 2083 "}"); |
2031 | 2084 |
2032 v8::Local<v8::Function> g; | 2085 v8::Local<v8::Function> g; |
2033 v8::Local<v8::String> script_g = v8::String::New( | 2086 v8::Local<v8::String> script_g = |
2034 "function g() {\n" | 2087 v8::String::NewFromUtf8(env->GetIsolate(), |
2035 " b = 0; // line 1\n" | 2088 "function g() {\n" |
2036 "}"); | 2089 " b = 0; // line 1\n" |
| 2090 "}"); |
2037 | 2091 |
2038 v8::ScriptOrigin origin = | 2092 v8::ScriptOrigin origin = |
2039 v8::ScriptOrigin(v8::String::New("test")); | 2093 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "test")); |
2040 | 2094 |
2041 // Set a script break point before the scripts are loaded. | 2095 // Set a script break point before the scripts are loaded. |
2042 int sbp = SetScriptBreakPointByNameFromJS("test", 1, 0); | 2096 int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); |
2043 | 2097 |
2044 // Compile the scripts with same script data and get the functions. | 2098 // Compile the scripts with same script data and get the functions. |
2045 v8::Script::Compile(script_f, &origin)->Run(); | 2099 v8::Script::Compile(script_f, &origin)->Run(); |
2046 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 2100 f = v8::Local<v8::Function>::Cast( |
| 2101 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
2047 v8::Script::Compile(script_g, &origin)->Run(); | 2102 v8::Script::Compile(script_g, &origin)->Run(); |
2048 g = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g"))); | 2103 g = v8::Local<v8::Function>::Cast( |
| 2104 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
2049 | 2105 |
2050 // Call f and g and check that the script break point is active. | 2106 // Call f and g and check that the script break point is active. |
2051 break_point_hit_count = 0; | 2107 break_point_hit_count = 0; |
2052 f->Call(env->Global(), 0, NULL); | 2108 f->Call(env->Global(), 0, NULL); |
2053 CHECK_EQ(1, break_point_hit_count); | 2109 CHECK_EQ(1, break_point_hit_count); |
2054 g->Call(env->Global(), 0, NULL); | 2110 g->Call(env->Global(), 0, NULL); |
2055 CHECK_EQ(2, break_point_hit_count); | 2111 CHECK_EQ(2, break_point_hit_count); |
2056 | 2112 |
2057 // Clear the script break point. | 2113 // Clear the script break point. |
2058 ClearBreakPointFromJS(sbp); | 2114 ClearBreakPointFromJS(env->GetIsolate(), sbp); |
2059 | 2115 |
2060 // Call f and g and check that the script break point is no longer active. | 2116 // Call f and g and check that the script break point is no longer active. |
2061 break_point_hit_count = 0; | 2117 break_point_hit_count = 0; |
2062 f->Call(env->Global(), 0, NULL); | 2118 f->Call(env->Global(), 0, NULL); |
2063 CHECK_EQ(0, break_point_hit_count); | 2119 CHECK_EQ(0, break_point_hit_count); |
2064 g->Call(env->Global(), 0, NULL); | 2120 g->Call(env->Global(), 0, NULL); |
2065 CHECK_EQ(0, break_point_hit_count); | 2121 CHECK_EQ(0, break_point_hit_count); |
2066 | 2122 |
2067 // Set script break point with the scripts loaded. | 2123 // Set script break point with the scripts loaded. |
2068 sbp = SetScriptBreakPointByNameFromJS("test", 1, 0); | 2124 sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); |
2069 | 2125 |
2070 // Call f and g and check that the script break point is active. | 2126 // Call f and g and check that the script break point is active. |
2071 break_point_hit_count = 0; | 2127 break_point_hit_count = 0; |
2072 f->Call(env->Global(), 0, NULL); | 2128 f->Call(env->Global(), 0, NULL); |
2073 CHECK_EQ(1, break_point_hit_count); | 2129 CHECK_EQ(1, break_point_hit_count); |
2074 g->Call(env->Global(), 0, NULL); | 2130 g->Call(env->Global(), 0, NULL); |
2075 CHECK_EQ(2, break_point_hit_count); | 2131 CHECK_EQ(2, break_point_hit_count); |
2076 | 2132 |
2077 v8::Debug::SetDebugEventListener2(NULL); | 2133 v8::Debug::SetDebugEventListener2(NULL); |
2078 CheckDebuggerUnloaded(); | 2134 CheckDebuggerUnloaded(); |
2079 } | 2135 } |
2080 | 2136 |
2081 | 2137 |
2082 // Test the script origin which has both name and line offset. | 2138 // Test the script origin which has both name and line offset. |
2083 TEST(ScriptBreakPointLineOffset) { | 2139 TEST(ScriptBreakPointLineOffset) { |
2084 break_point_hit_count = 0; | 2140 break_point_hit_count = 0; |
2085 DebugLocalContext env; | 2141 DebugLocalContext env; |
2086 v8::HandleScope scope(env->GetIsolate()); | 2142 v8::HandleScope scope(env->GetIsolate()); |
2087 env.ExposeDebug(); | 2143 env.ExposeDebug(); |
2088 | 2144 |
2089 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 2145 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
2090 | 2146 |
2091 v8::Local<v8::Function> f; | 2147 v8::Local<v8::Function> f; |
2092 v8::Local<v8::String> script = v8::String::New( | 2148 v8::Local<v8::String> script = v8::String::NewFromUtf8( |
2093 "function f() {\n" | 2149 env->GetIsolate(), |
2094 " a = 0; // line 8 as this script has line offset 7\n" | 2150 "function f() {\n" |
2095 " b = 0; // line 9 as this script has line offset 7\n" | 2151 " a = 0; // line 8 as this script has line offset 7\n" |
2096 "}"); | 2152 " b = 0; // line 9 as this script has line offset 7\n" |
| 2153 "}"); |
2097 | 2154 |
2098 // Create script origin both name and line offset. | 2155 // Create script origin both name and line offset. |
2099 v8::ScriptOrigin origin(v8::String::New("test.html"), | 2156 v8::ScriptOrigin origin( |
2100 v8::Integer::New(7)); | 2157 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"), |
| 2158 v8::Integer::New(7)); |
2101 | 2159 |
2102 // Set two script break points before the script is loaded. | 2160 // Set two script break points before the script is loaded. |
2103 int sbp1 = SetScriptBreakPointByNameFromJS("test.html", 8, 0); | 2161 int sbp1 = |
2104 int sbp2 = SetScriptBreakPointByNameFromJS("test.html", 9, 0); | 2162 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 8, 0); |
| 2163 int sbp2 = |
| 2164 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0); |
2105 | 2165 |
2106 // Compile the script and get the function. | 2166 // Compile the script and get the function. |
2107 v8::Script::Compile(script, &origin)->Run(); | 2167 v8::Script::Compile(script, &origin)->Run(); |
2108 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 2168 f = v8::Local<v8::Function>::Cast( |
| 2169 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
2109 | 2170 |
2110 // Call f and check that the script break point is active. | 2171 // Call f and check that the script break point is active. |
2111 break_point_hit_count = 0; | 2172 break_point_hit_count = 0; |
2112 f->Call(env->Global(), 0, NULL); | 2173 f->Call(env->Global(), 0, NULL); |
2113 CHECK_EQ(2, break_point_hit_count); | 2174 CHECK_EQ(2, break_point_hit_count); |
2114 | 2175 |
2115 // Clear the script break points. | 2176 // Clear the script break points. |
2116 ClearBreakPointFromJS(sbp1); | 2177 ClearBreakPointFromJS(env->GetIsolate(), sbp1); |
2117 ClearBreakPointFromJS(sbp2); | 2178 ClearBreakPointFromJS(env->GetIsolate(), sbp2); |
2118 | 2179 |
2119 // Call f and check that no script break points are active. | 2180 // Call f and check that no script break points are active. |
2120 break_point_hit_count = 0; | 2181 break_point_hit_count = 0; |
2121 f->Call(env->Global(), 0, NULL); | 2182 f->Call(env->Global(), 0, NULL); |
2122 CHECK_EQ(0, break_point_hit_count); | 2183 CHECK_EQ(0, break_point_hit_count); |
2123 | 2184 |
2124 // Set a script break point with the script loaded. | 2185 // Set a script break point with the script loaded. |
2125 sbp1 = SetScriptBreakPointByNameFromJS("test.html", 9, 0); | 2186 sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 9, 0); |
2126 | 2187 |
2127 // Call f and check that the script break point is active. | 2188 // Call f and check that the script break point is active. |
2128 break_point_hit_count = 0; | 2189 break_point_hit_count = 0; |
2129 f->Call(env->Global(), 0, NULL); | 2190 f->Call(env->Global(), 0, NULL); |
2130 CHECK_EQ(1, break_point_hit_count); | 2191 CHECK_EQ(1, break_point_hit_count); |
2131 | 2192 |
2132 v8::Debug::SetDebugEventListener2(NULL); | 2193 v8::Debug::SetDebugEventListener2(NULL); |
2133 CheckDebuggerUnloaded(); | 2194 CheckDebuggerUnloaded(); |
2134 } | 2195 } |
2135 | 2196 |
2136 | 2197 |
2137 // Test script break points set on lines. | 2198 // Test script break points set on lines. |
2138 TEST(ScriptBreakPointLine) { | 2199 TEST(ScriptBreakPointLine) { |
2139 DebugLocalContext env; | 2200 DebugLocalContext env; |
2140 v8::HandleScope scope(env->GetIsolate()); | 2201 v8::HandleScope scope(env->GetIsolate()); |
2141 env.ExposeDebug(); | 2202 env.ExposeDebug(); |
2142 | 2203 |
2143 // Create a function for checking the function when hitting a break point. | 2204 // Create a function for checking the function when hitting a break point. |
2144 frame_function_name = CompileFunction(&env, | 2205 frame_function_name = CompileFunction(&env, |
2145 frame_function_name_source, | 2206 frame_function_name_source, |
2146 "frame_function_name"); | 2207 "frame_function_name"); |
2147 | 2208 |
2148 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 2209 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
2149 | 2210 |
2150 v8::Local<v8::Function> f; | 2211 v8::Local<v8::Function> f; |
2151 v8::Local<v8::Function> g; | 2212 v8::Local<v8::Function> g; |
2152 v8::Local<v8::String> script = v8::String::New( | 2213 v8::Local<v8::String> script = |
2153 "a = 0 // line 0\n" | 2214 v8::String::NewFromUtf8(env->GetIsolate(), |
2154 "function f() {\n" | 2215 "a = 0 // line 0\n" |
2155 " a = 1; // line 2\n" | 2216 "function f() {\n" |
2156 "}\n" | 2217 " a = 1; // line 2\n" |
2157 " a = 2; // line 4\n" | 2218 "}\n" |
2158 " /* xx */ function g() { // line 5\n" | 2219 " a = 2; // line 4\n" |
2159 " function h() { // line 6\n" | 2220 " /* xx */ function g() { // line 5\n" |
2160 " a = 3; // line 7\n" | 2221 " function h() { // line 6\n" |
2161 " }\n" | 2222 " a = 3; // line 7\n" |
2162 " h(); // line 9\n" | 2223 " }\n" |
2163 " a = 4; // line 10\n" | 2224 " h(); // line 9\n" |
2164 " }\n" | 2225 " a = 4; // line 10\n" |
2165 " a=5; // line 12"); | 2226 " }\n" |
| 2227 " a=5; // line 12"); |
2166 | 2228 |
2167 // Set a couple script break point before the script is loaded. | 2229 // Set a couple script break point before the script is loaded. |
2168 int sbp1 = SetScriptBreakPointByNameFromJS("test.html", 0, -1); | 2230 int sbp1 = |
2169 int sbp2 = SetScriptBreakPointByNameFromJS("test.html", 1, -1); | 2231 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 0, -1); |
2170 int sbp3 = SetScriptBreakPointByNameFromJS("test.html", 5, -1); | 2232 int sbp2 = |
| 2233 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 1, -1); |
| 2234 int sbp3 = |
| 2235 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 5, -1); |
2171 | 2236 |
2172 // Compile the script and get the function. | 2237 // Compile the script and get the function. |
2173 break_point_hit_count = 0; | 2238 break_point_hit_count = 0; |
2174 v8::ScriptOrigin origin(v8::String::New("test.html"), v8::Integer::New(0)); | 2239 v8::ScriptOrigin origin( |
| 2240 v8::String::NewFromUtf8(env->GetIsolate(), "test.html"), |
| 2241 v8::Integer::New(0)); |
2175 v8::Script::Compile(script, &origin)->Run(); | 2242 v8::Script::Compile(script, &origin)->Run(); |
2176 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 2243 f = v8::Local<v8::Function>::Cast( |
2177 g = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g"))); | 2244 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
| 2245 g = v8::Local<v8::Function>::Cast( |
| 2246 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
2178 | 2247 |
2179 // Check that a break point was hit when the script was run. | 2248 // Check that a break point was hit when the script was run. |
2180 CHECK_EQ(1, break_point_hit_count); | 2249 CHECK_EQ(1, break_point_hit_count); |
2181 CHECK_EQ(0, StrLength(last_function_hit)); | 2250 CHECK_EQ(0, StrLength(last_function_hit)); |
2182 | 2251 |
2183 // Call f and check that the script break point. | 2252 // Call f and check that the script break point. |
2184 f->Call(env->Global(), 0, NULL); | 2253 f->Call(env->Global(), 0, NULL); |
2185 CHECK_EQ(2, break_point_hit_count); | 2254 CHECK_EQ(2, break_point_hit_count); |
2186 CHECK_EQ("f", last_function_hit); | 2255 CHECK_EQ("f", last_function_hit); |
2187 | 2256 |
2188 // Call g and check that the script break point. | 2257 // Call g and check that the script break point. |
2189 g->Call(env->Global(), 0, NULL); | 2258 g->Call(env->Global(), 0, NULL); |
2190 CHECK_EQ(3, break_point_hit_count); | 2259 CHECK_EQ(3, break_point_hit_count); |
2191 CHECK_EQ("g", last_function_hit); | 2260 CHECK_EQ("g", last_function_hit); |
2192 | 2261 |
2193 // Clear the script break point on g and set one on h. | 2262 // Clear the script break point on g and set one on h. |
2194 ClearBreakPointFromJS(sbp3); | 2263 ClearBreakPointFromJS(env->GetIsolate(), sbp3); |
2195 int sbp4 = SetScriptBreakPointByNameFromJS("test.html", 6, -1); | 2264 int sbp4 = |
| 2265 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 6, -1); |
2196 | 2266 |
2197 // Call g and check that the script break point in h is hit. | 2267 // Call g and check that the script break point in h is hit. |
2198 g->Call(env->Global(), 0, NULL); | 2268 g->Call(env->Global(), 0, NULL); |
2199 CHECK_EQ(4, break_point_hit_count); | 2269 CHECK_EQ(4, break_point_hit_count); |
2200 CHECK_EQ("h", last_function_hit); | 2270 CHECK_EQ("h", last_function_hit); |
2201 | 2271 |
2202 // Clear break points in f and h. Set a new one in the script between | 2272 // Clear break points in f and h. Set a new one in the script between |
2203 // functions f and g and test that there is no break points in f and g any | 2273 // functions f and g and test that there is no break points in f and g any |
2204 // more. | 2274 // more. |
2205 ClearBreakPointFromJS(sbp2); | 2275 ClearBreakPointFromJS(env->GetIsolate(), sbp2); |
2206 ClearBreakPointFromJS(sbp4); | 2276 ClearBreakPointFromJS(env->GetIsolate(), sbp4); |
2207 int sbp5 = SetScriptBreakPointByNameFromJS("test.html", 4, -1); | 2277 int sbp5 = |
| 2278 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 4, -1); |
2208 break_point_hit_count = 0; | 2279 break_point_hit_count = 0; |
2209 f->Call(env->Global(), 0, NULL); | 2280 f->Call(env->Global(), 0, NULL); |
2210 g->Call(env->Global(), 0, NULL); | 2281 g->Call(env->Global(), 0, NULL); |
2211 CHECK_EQ(0, break_point_hit_count); | 2282 CHECK_EQ(0, break_point_hit_count); |
2212 | 2283 |
2213 // Reload the script which should hit two break points. | 2284 // Reload the script which should hit two break points. |
2214 break_point_hit_count = 0; | 2285 break_point_hit_count = 0; |
2215 v8::Script::Compile(script, &origin)->Run(); | 2286 v8::Script::Compile(script, &origin)->Run(); |
2216 CHECK_EQ(2, break_point_hit_count); | 2287 CHECK_EQ(2, break_point_hit_count); |
2217 CHECK_EQ(0, StrLength(last_function_hit)); | 2288 CHECK_EQ(0, StrLength(last_function_hit)); |
2218 | 2289 |
2219 // Set a break point in the code after the last function decleration. | 2290 // Set a break point in the code after the last function decleration. |
2220 int sbp6 = SetScriptBreakPointByNameFromJS("test.html", 12, -1); | 2291 int sbp6 = |
| 2292 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 12, -1); |
2221 | 2293 |
2222 // Reload the script which should hit three break points. | 2294 // Reload the script which should hit three break points. |
2223 break_point_hit_count = 0; | 2295 break_point_hit_count = 0; |
2224 v8::Script::Compile(script, &origin)->Run(); | 2296 v8::Script::Compile(script, &origin)->Run(); |
2225 CHECK_EQ(3, break_point_hit_count); | 2297 CHECK_EQ(3, break_point_hit_count); |
2226 CHECK_EQ(0, StrLength(last_function_hit)); | 2298 CHECK_EQ(0, StrLength(last_function_hit)); |
2227 | 2299 |
2228 // Clear the last break points, and reload the script which should not hit any | 2300 // Clear the last break points, and reload the script which should not hit any |
2229 // break points. | 2301 // break points. |
2230 ClearBreakPointFromJS(sbp1); | 2302 ClearBreakPointFromJS(env->GetIsolate(), sbp1); |
2231 ClearBreakPointFromJS(sbp5); | 2303 ClearBreakPointFromJS(env->GetIsolate(), sbp5); |
2232 ClearBreakPointFromJS(sbp6); | 2304 ClearBreakPointFromJS(env->GetIsolate(), sbp6); |
2233 break_point_hit_count = 0; | 2305 break_point_hit_count = 0; |
2234 v8::Script::Compile(script, &origin)->Run(); | 2306 v8::Script::Compile(script, &origin)->Run(); |
2235 CHECK_EQ(0, break_point_hit_count); | 2307 CHECK_EQ(0, break_point_hit_count); |
2236 | 2308 |
2237 v8::Debug::SetDebugEventListener2(NULL); | 2309 v8::Debug::SetDebugEventListener2(NULL); |
2238 CheckDebuggerUnloaded(); | 2310 CheckDebuggerUnloaded(); |
2239 } | 2311 } |
2240 | 2312 |
2241 | 2313 |
2242 // Test top level script break points set on lines. | 2314 // Test top level script break points set on lines. |
2243 TEST(ScriptBreakPointLineTopLevel) { | 2315 TEST(ScriptBreakPointLineTopLevel) { |
2244 DebugLocalContext env; | 2316 DebugLocalContext env; |
2245 v8::HandleScope scope(env->GetIsolate()); | 2317 v8::HandleScope scope(env->GetIsolate()); |
2246 env.ExposeDebug(); | 2318 env.ExposeDebug(); |
2247 | 2319 |
2248 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 2320 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
2249 | 2321 |
2250 v8::Local<v8::String> script = v8::String::New( | 2322 v8::Local<v8::String> script = |
2251 "function f() {\n" | 2323 v8::String::NewFromUtf8(env->GetIsolate(), |
2252 " a = 1; // line 1\n" | 2324 "function f() {\n" |
2253 "}\n" | 2325 " a = 1; // line 1\n" |
2254 "a = 2; // line 3\n"); | 2326 "}\n" |
| 2327 "a = 2; // line 3\n"); |
2255 v8::Local<v8::Function> f; | 2328 v8::Local<v8::Function> f; |
2256 { | 2329 { |
2257 v8::HandleScope scope(env->GetIsolate()); | 2330 v8::HandleScope scope(env->GetIsolate()); |
2258 v8::Script::Compile(script, v8::String::New("test.html"))->Run(); | 2331 v8::Script::Compile( |
| 2332 script, v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))->Run(); |
2259 } | 2333 } |
2260 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 2334 f = v8::Local<v8::Function>::Cast( |
| 2335 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
2261 | 2336 |
2262 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 2337 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
2263 | 2338 |
2264 SetScriptBreakPointByNameFromJS("test.html", 3, -1); | 2339 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); |
2265 | 2340 |
2266 // Call f and check that there was no break points. | 2341 // Call f and check that there was no break points. |
2267 break_point_hit_count = 0; | 2342 break_point_hit_count = 0; |
2268 f->Call(env->Global(), 0, NULL); | 2343 f->Call(env->Global(), 0, NULL); |
2269 CHECK_EQ(0, break_point_hit_count); | 2344 CHECK_EQ(0, break_point_hit_count); |
2270 | 2345 |
2271 // Recompile and run script and check that break point was hit. | 2346 // Recompile and run script and check that break point was hit. |
2272 break_point_hit_count = 0; | 2347 break_point_hit_count = 0; |
2273 v8::Script::Compile(script, v8::String::New("test.html"))->Run(); | 2348 v8::Script::Compile( |
| 2349 script, v8::String::NewFromUtf8(env->GetIsolate(), "test.html"))->Run(); |
2274 CHECK_EQ(1, break_point_hit_count); | 2350 CHECK_EQ(1, break_point_hit_count); |
2275 | 2351 |
2276 // Call f and check that there are still no break points. | 2352 // Call f and check that there are still no break points. |
2277 break_point_hit_count = 0; | 2353 break_point_hit_count = 0; |
2278 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 2354 f = v8::Local<v8::Function>::Cast( |
| 2355 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
2279 CHECK_EQ(0, break_point_hit_count); | 2356 CHECK_EQ(0, break_point_hit_count); |
2280 | 2357 |
2281 v8::Debug::SetDebugEventListener2(NULL); | 2358 v8::Debug::SetDebugEventListener2(NULL); |
2282 CheckDebuggerUnloaded(); | 2359 CheckDebuggerUnloaded(); |
2283 } | 2360 } |
2284 | 2361 |
2285 | 2362 |
2286 // Test that it is possible to add and remove break points in a top level | 2363 // Test that it is possible to add and remove break points in a top level |
2287 // function which has no references but has not been collected yet. | 2364 // function which has no references but has not been collected yet. |
2288 TEST(ScriptBreakPointTopLevelCrash) { | 2365 TEST(ScriptBreakPointTopLevelCrash) { |
2289 DebugLocalContext env; | 2366 DebugLocalContext env; |
2290 v8::HandleScope scope(env->GetIsolate()); | 2367 v8::HandleScope scope(env->GetIsolate()); |
2291 env.ExposeDebug(); | 2368 env.ExposeDebug(); |
2292 | 2369 |
2293 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 2370 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
2294 | 2371 |
2295 v8::Local<v8::String> script_source = v8::String::New( | 2372 v8::Local<v8::String> script_source = |
2296 "function f() {\n" | 2373 v8::String::NewFromUtf8(env->GetIsolate(), |
2297 " return 0;\n" | 2374 "function f() {\n" |
2298 "}\n" | 2375 " return 0;\n" |
2299 "f()"); | 2376 "}\n" |
| 2377 "f()"); |
2300 | 2378 |
2301 int sbp1 = SetScriptBreakPointByNameFromJS("test.html", 3, -1); | 2379 int sbp1 = |
| 2380 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); |
2302 { | 2381 { |
2303 v8::HandleScope scope(env->GetIsolate()); | 2382 v8::HandleScope scope(env->GetIsolate()); |
2304 break_point_hit_count = 0; | 2383 break_point_hit_count = 0; |
2305 v8::Script::Compile(script_source, v8::String::New("test.html"))->Run(); | 2384 v8::Script::Compile(script_source, |
| 2385 v8::String::NewFromUtf8(env->GetIsolate(), "test.html")) |
| 2386 ->Run(); |
2306 CHECK_EQ(1, break_point_hit_count); | 2387 CHECK_EQ(1, break_point_hit_count); |
2307 } | 2388 } |
2308 | 2389 |
2309 int sbp2 = SetScriptBreakPointByNameFromJS("test.html", 3, -1); | 2390 int sbp2 = |
2310 ClearBreakPointFromJS(sbp1); | 2391 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); |
2311 ClearBreakPointFromJS(sbp2); | 2392 ClearBreakPointFromJS(env->GetIsolate(), sbp1); |
| 2393 ClearBreakPointFromJS(env->GetIsolate(), sbp2); |
2312 | 2394 |
2313 v8::Debug::SetDebugEventListener2(NULL); | 2395 v8::Debug::SetDebugEventListener2(NULL); |
2314 CheckDebuggerUnloaded(); | 2396 CheckDebuggerUnloaded(); |
2315 } | 2397 } |
2316 | 2398 |
2317 | 2399 |
2318 // Test that it is possible to remove the last break point for a function | 2400 // Test that it is possible to remove the last break point for a function |
2319 // inside the break handling of that break point. | 2401 // inside the break handling of that break point. |
2320 TEST(RemoveBreakPointInBreak) { | 2402 TEST(RemoveBreakPointInBreak) { |
2321 DebugLocalContext env; | 2403 DebugLocalContext env; |
(...skipping 18 matching lines...) Expand all Loading... |
2340 CheckDebuggerUnloaded(); | 2422 CheckDebuggerUnloaded(); |
2341 } | 2423 } |
2342 | 2424 |
2343 | 2425 |
2344 // Test that the debugger statement causes a break. | 2426 // Test that the debugger statement causes a break. |
2345 TEST(DebuggerStatement) { | 2427 TEST(DebuggerStatement) { |
2346 break_point_hit_count = 0; | 2428 break_point_hit_count = 0; |
2347 DebugLocalContext env; | 2429 DebugLocalContext env; |
2348 v8::HandleScope scope(env->GetIsolate()); | 2430 v8::HandleScope scope(env->GetIsolate()); |
2349 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 2431 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
2350 v8::Script::Compile(v8::String::New("function bar(){debugger}"))->Run(); | 2432 v8::Script::Compile( |
2351 v8::Script::Compile(v8::String::New( | 2433 v8::String::NewFromUtf8(env->GetIsolate(), "function bar(){debugger}")) |
2352 "function foo(){debugger;debugger;}"))->Run(); | 2434 ->Run(); |
2353 v8::Local<v8::Function> foo = | 2435 v8::Script::Compile( |
2354 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); | 2436 v8::String::NewFromUtf8(env->GetIsolate(), |
2355 v8::Local<v8::Function> bar = | 2437 "function foo(){debugger;debugger;}"))->Run(); |
2356 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("bar"))); | 2438 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 2439 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
| 2440 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast( |
| 2441 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "bar"))); |
2357 | 2442 |
2358 // Run function with debugger statement | 2443 // Run function with debugger statement |
2359 bar->Call(env->Global(), 0, NULL); | 2444 bar->Call(env->Global(), 0, NULL); |
2360 CHECK_EQ(1, break_point_hit_count); | 2445 CHECK_EQ(1, break_point_hit_count); |
2361 | 2446 |
2362 // Run function with two debugger statement | 2447 // Run function with two debugger statement |
2363 foo->Call(env->Global(), 0, NULL); | 2448 foo->Call(env->Global(), 0, NULL); |
2364 CHECK_EQ(3, break_point_hit_count); | 2449 CHECK_EQ(3, break_point_hit_count); |
2365 | 2450 |
2366 v8::Debug::SetDebugEventListener2(NULL); | 2451 v8::Debug::SetDebugEventListener2(NULL); |
2367 CheckDebuggerUnloaded(); | 2452 CheckDebuggerUnloaded(); |
2368 } | 2453 } |
2369 | 2454 |
2370 | 2455 |
2371 // Test setting a breakpoint on the debugger statement. | 2456 // Test setting a breakpoint on the debugger statement. |
2372 TEST(DebuggerStatementBreakpoint) { | 2457 TEST(DebuggerStatementBreakpoint) { |
2373 break_point_hit_count = 0; | 2458 break_point_hit_count = 0; |
2374 DebugLocalContext env; | 2459 DebugLocalContext env; |
2375 v8::HandleScope scope(env->GetIsolate()); | 2460 v8::HandleScope scope(env->GetIsolate()); |
2376 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 2461 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
2377 v8::Script::Compile(v8::String::New("function foo(){debugger;}"))->Run(); | 2462 v8::Script::Compile( |
2378 v8::Local<v8::Function> foo = | 2463 v8::String::NewFromUtf8(env->GetIsolate(), "function foo(){debugger;}")) |
2379 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); | 2464 ->Run(); |
| 2465 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
| 2466 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo"))); |
2380 | 2467 |
2381 // The debugger statement triggers breakpint hit | 2468 // The debugger statement triggers breakpint hit |
2382 foo->Call(env->Global(), 0, NULL); | 2469 foo->Call(env->Global(), 0, NULL); |
2383 CHECK_EQ(1, break_point_hit_count); | 2470 CHECK_EQ(1, break_point_hit_count); |
2384 | 2471 |
2385 int bp = SetBreakPoint(foo, 0); | 2472 int bp = SetBreakPoint(foo, 0); |
2386 | 2473 |
2387 // Set breakpoint does not duplicate hits | 2474 // Set breakpoint does not duplicate hits |
2388 foo->Call(env->Global(), 0, NULL); | 2475 foo->Call(env->Global(), 0, NULL); |
2389 CHECK_EQ(2, break_point_hit_count); | 2476 CHECK_EQ(2, break_point_hit_count); |
(...skipping 20 matching lines...) Expand all Loading... |
2410 v8::Debug::SetDebugEventListener2(DebugEventEvaluate); | 2497 v8::Debug::SetDebugEventListener2(DebugEventEvaluate); |
2411 | 2498 |
2412 // Different expected vaules of x and a when in a break point (u = undefined, | 2499 // Different expected vaules of x and a when in a break point (u = undefined, |
2413 // d = Hello, world!). | 2500 // d = Hello, world!). |
2414 struct EvaluateCheck checks_uu[] = { | 2501 struct EvaluateCheck checks_uu[] = { |
2415 {"x", v8::Undefined(isolate)}, | 2502 {"x", v8::Undefined(isolate)}, |
2416 {"a", v8::Undefined(isolate)}, | 2503 {"a", v8::Undefined(isolate)}, |
2417 {NULL, v8::Handle<v8::Value>()} | 2504 {NULL, v8::Handle<v8::Value>()} |
2418 }; | 2505 }; |
2419 struct EvaluateCheck checks_hu[] = { | 2506 struct EvaluateCheck checks_hu[] = { |
2420 {"x", v8::String::New("Hello, world!")}, | 2507 {"x", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")}, |
2421 {"a", v8::Undefined(isolate)}, | 2508 {"a", v8::Undefined(isolate)}, |
2422 {NULL, v8::Handle<v8::Value>()} | 2509 {NULL, v8::Handle<v8::Value>()} |
2423 }; | 2510 }; |
2424 struct EvaluateCheck checks_hh[] = { | 2511 struct EvaluateCheck checks_hh[] = { |
2425 {"x", v8::String::New("Hello, world!")}, | 2512 {"x", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")}, |
2426 {"a", v8::String::New("Hello, world!")}, | 2513 {"a", v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")}, |
2427 {NULL, v8::Handle<v8::Value>()} | 2514 {NULL, v8::Handle<v8::Value>()} |
2428 }; | 2515 }; |
2429 | 2516 |
2430 // Simple test function. The "y=0" is in the function foo to provide a break | 2517 // Simple test function. The "y=0" is in the function foo to provide a break |
2431 // location. For "y=0" the "y" is at position 15 in the barbar function | 2518 // location. For "y=0" the "y" is at position 15 in the barbar function |
2432 // therefore setting breakpoint at position 15 will break at "y=0" and | 2519 // therefore setting breakpoint at position 15 will break at "y=0" and |
2433 // setting it higher will break after. | 2520 // setting it higher will break after. |
2434 v8::Local<v8::Function> foo = CompileFunction(&env, | 2521 v8::Local<v8::Function> foo = CompileFunction(&env, |
2435 "function foo(x) {" | 2522 "function foo(x) {" |
2436 " var a;" | 2523 " var a;" |
2437 " y=0;" // To ensure break location 1. | 2524 " y=0;" // To ensure break location 1. |
2438 " a=x;" | 2525 " a=x;" |
2439 " y=0;" // To ensure break location 2. | 2526 " y=0;" // To ensure break location 2. |
2440 "}", | 2527 "}", |
2441 "foo"); | 2528 "foo"); |
2442 const int foo_break_position_1 = 15; | 2529 const int foo_break_position_1 = 15; |
2443 const int foo_break_position_2 = 29; | 2530 const int foo_break_position_2 = 29; |
2444 | 2531 |
2445 // Arguments with one parameter "Hello, world!" | 2532 // Arguments with one parameter "Hello, world!" |
2446 v8::Handle<v8::Value> argv_foo[1] = { v8::String::New("Hello, world!") }; | 2533 v8::Handle<v8::Value> argv_foo[1] = { |
| 2534 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")}; |
2447 | 2535 |
2448 // Call foo with breakpoint set before a=x and undefined as parameter. | 2536 // Call foo with breakpoint set before a=x and undefined as parameter. |
2449 int bp = SetBreakPoint(foo, foo_break_position_1); | 2537 int bp = SetBreakPoint(foo, foo_break_position_1); |
2450 checks = checks_uu; | 2538 checks = checks_uu; |
2451 foo->Call(env->Global(), 0, NULL); | 2539 foo->Call(env->Global(), 0, NULL); |
2452 | 2540 |
2453 // Call foo with breakpoint set before a=x and parameter "Hello, world!". | 2541 // Call foo with breakpoint set before a=x and parameter "Hello, world!". |
2454 checks = checks_hu; | 2542 checks = checks_hu; |
2455 foo->Call(env->Global(), 1, argv_foo); | 2543 foo->Call(env->Global(), 1, argv_foo); |
2456 | 2544 |
(...skipping 29 matching lines...) Expand all Loading... |
2486 v8::Handle<v8::Value> argv_bar_1[2] = { | 2574 v8::Handle<v8::Value> argv_bar_1[2] = { |
2487 v8::Undefined(isolate), | 2575 v8::Undefined(isolate), |
2488 v8::Number::New(barbar_break_position) | 2576 v8::Number::New(barbar_break_position) |
2489 }; | 2577 }; |
2490 bar->Call(env->Global(), 2, argv_bar_1); | 2578 bar->Call(env->Global(), 2, argv_bar_1); |
2491 | 2579 |
2492 // Call bar setting breakpoint before a=x in barbar and parameter | 2580 // Call bar setting breakpoint before a=x in barbar and parameter |
2493 // "Hello, world!". | 2581 // "Hello, world!". |
2494 checks = checks_hu; | 2582 checks = checks_hu; |
2495 v8::Handle<v8::Value> argv_bar_2[2] = { | 2583 v8::Handle<v8::Value> argv_bar_2[2] = { |
2496 v8::String::New("Hello, world!"), | 2584 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"), |
2497 v8::Number::New(barbar_break_position) | 2585 v8::Number::New(barbar_break_position) |
2498 }; | 2586 }; |
2499 bar->Call(env->Global(), 2, argv_bar_2); | 2587 bar->Call(env->Global(), 2, argv_bar_2); |
2500 | 2588 |
2501 // Call bar setting breakpoint after a=x in barbar and parameter | 2589 // Call bar setting breakpoint after a=x in barbar and parameter |
2502 // "Hello, world!". | 2590 // "Hello, world!". |
2503 checks = checks_hh; | 2591 checks = checks_hh; |
2504 v8::Handle<v8::Value> argv_bar_3[2] = { | 2592 v8::Handle<v8::Value> argv_bar_3[2] = { |
2505 v8::String::New("Hello, world!"), | 2593 v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!"), |
2506 v8::Number::New(barbar_break_position + 1) | 2594 v8::Number::New(barbar_break_position + 1) |
2507 }; | 2595 }; |
2508 bar->Call(env->Global(), 2, argv_bar_3); | 2596 bar->Call(env->Global(), 2, argv_bar_3); |
2509 | 2597 |
2510 v8::Debug::SetDebugEventListener2(NULL); | 2598 v8::Debug::SetDebugEventListener2(NULL); |
2511 CheckDebuggerUnloaded(); | 2599 CheckDebuggerUnloaded(); |
2512 } | 2600 } |
2513 | 2601 |
2514 | 2602 |
2515 int debugEventCount = 0; | 2603 int debugEventCount = 0; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2683 void next() { | 2771 void next() { |
2684 counter++; | 2772 counter++; |
2685 } | 2773 } |
2686 }; | 2774 }; |
2687 | 2775 |
2688 DebugProcessDebugMessagesData process_debug_messages_data; | 2776 DebugProcessDebugMessagesData process_debug_messages_data; |
2689 | 2777 |
2690 static void DebugProcessDebugMessagesHandler( | 2778 static void DebugProcessDebugMessagesHandler( |
2691 const v8::Debug::Message& message) { | 2779 const v8::Debug::Message& message) { |
2692 v8::Handle<v8::String> json = message.GetJSON(); | 2780 v8::Handle<v8::String> json = message.GetJSON(); |
2693 v8::String::AsciiValue ascii(json); | 2781 v8::String::Utf8Value utf8(json); |
2694 EvaluateResult* array_item = process_debug_messages_data.current(); | 2782 EvaluateResult* array_item = process_debug_messages_data.current(); |
2695 | 2783 |
2696 bool res = GetEvaluateStringResult(*ascii, | 2784 bool res = GetEvaluateStringResult(*utf8, |
2697 array_item->buffer, | 2785 array_item->buffer, |
2698 EvaluateResult::kBufferSize); | 2786 EvaluateResult::kBufferSize); |
2699 if (res) { | 2787 if (res) { |
2700 process_debug_messages_data.next(); | 2788 process_debug_messages_data.next(); |
2701 } | 2789 } |
2702 } | 2790 } |
2703 | 2791 |
2704 | 2792 |
2705 // Test that the evaluation of expressions works even from ProcessDebugMessages | 2793 // Test that the evaluation of expressions works even from ProcessDebugMessages |
2706 // i.e. with empty stack. | 2794 // i.e. with empty stack. |
2707 TEST(DebugEvaluateWithoutStack) { | 2795 TEST(DebugEvaluateWithoutStack) { |
2708 v8::Debug::SetMessageHandler2(DebugProcessDebugMessagesHandler); | 2796 v8::Debug::SetMessageHandler2(DebugProcessDebugMessagesHandler); |
2709 | 2797 |
2710 DebugLocalContext env; | 2798 DebugLocalContext env; |
2711 v8::HandleScope scope(env->GetIsolate()); | 2799 v8::HandleScope scope(env->GetIsolate()); |
2712 | 2800 |
2713 const char* source = | 2801 const char* source = |
2714 "var v1 = 'Pinguin';\n function getAnimal() { return 'Capy' + 'bara'; }"; | 2802 "var v1 = 'Pinguin';\n function getAnimal() { return 'Capy' + 'bara'; }"; |
2715 | 2803 |
2716 v8::Script::Compile(v8::String::New(source))->Run(); | 2804 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source)) |
| 2805 ->Run(); |
2717 | 2806 |
2718 v8::Debug::ProcessDebugMessages(); | 2807 v8::Debug::ProcessDebugMessages(); |
2719 | 2808 |
2720 const int kBufferSize = 1000; | 2809 const int kBufferSize = 1000; |
2721 uint16_t buffer[kBufferSize]; | 2810 uint16_t buffer[kBufferSize]; |
2722 | 2811 |
2723 const char* command_111 = "{\"seq\":111," | 2812 const char* command_111 = "{\"seq\":111," |
2724 "\"type\":\"request\"," | 2813 "\"type\":\"request\"," |
2725 "\"command\":\"evaluate\"," | 2814 "\"command\":\"evaluate\"," |
2726 "\"arguments\":{" | 2815 "\"arguments\":{" |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3482 v8::Debug::SetDebugEventListener2(DebugEventStep); | 3571 v8::Debug::SetDebugEventListener2(DebugEventStep); |
3483 | 3572 |
3484 // Create a function for testing stepping. Run it to allow it to get | 3573 // Create a function for testing stepping. Run it to allow it to get |
3485 // optimized. | 3574 // optimized. |
3486 const char* src = "function foo(x) { " | 3575 const char* src = "function foo(x) { " |
3487 " var a = {};" | 3576 " var a = {};" |
3488 " with (a) {}" | 3577 " with (a) {}" |
3489 " with (b) {}" | 3578 " with (b) {}" |
3490 "}" | 3579 "}" |
3491 "foo()"; | 3580 "foo()"; |
3492 env->Global()->Set(v8::String::New("b"), v8::Object::New()); | 3581 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"), |
| 3582 v8::Object::New()); |
3493 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); | 3583 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
3494 v8::Handle<v8::Value> result; | 3584 v8::Handle<v8::Value> result; |
3495 SetBreakPoint(foo, 8); // "var a = {};" | 3585 SetBreakPoint(foo, 8); // "var a = {};" |
3496 | 3586 |
3497 step_action = StepIn; | 3587 step_action = StepIn; |
3498 break_point_hit_count = 0; | 3588 break_point_hit_count = 0; |
3499 foo->Call(env->Global(), 0, NULL); | 3589 foo->Call(env->Global(), 0, NULL); |
3500 CHECK_EQ(4, break_point_hit_count); | 3590 CHECK_EQ(4, break_point_hit_count); |
3501 | 3591 |
3502 // Get rid of the debug event listener. | 3592 // Get rid of the debug event listener. |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3816 env.ExposeDebug(); | 3906 env.ExposeDebug(); |
3817 | 3907 |
3818 // Register a debug event listener which counts. | 3908 // Register a debug event listener which counts. |
3819 v8::Debug::SetDebugEventListener2(DebugEventCounter); | 3909 v8::Debug::SetDebugEventListener2(DebugEventCounter); |
3820 | 3910 |
3821 // Create a script that returns a function. | 3911 // Create a script that returns a function. |
3822 const char* src = "(function (evt) {})"; | 3912 const char* src = "(function (evt) {})"; |
3823 const char* script_name = "StepInHandlerTest"; | 3913 const char* script_name = "StepInHandlerTest"; |
3824 | 3914 |
3825 // Set breakpoint in the script. | 3915 // Set breakpoint in the script. |
3826 SetScriptBreakPointByNameFromJS(script_name, 0, -1); | 3916 SetScriptBreakPointByNameFromJS(env->GetIsolate(), script_name, 0, -1); |
3827 break_point_hit_count = 0; | 3917 break_point_hit_count = 0; |
3828 | 3918 |
3829 v8::ScriptOrigin origin(v8::String::New(script_name), v8::Integer::New(0)); | 3919 v8::ScriptOrigin origin( |
3830 v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(src), | 3920 v8::String::NewFromUtf8(env->GetIsolate(), script_name), |
3831 &origin); | 3921 v8::Integer::New(0)); |
| 3922 v8::Handle<v8::Script> script = v8::Script::Compile( |
| 3923 v8::String::NewFromUtf8(env->GetIsolate(), src), &origin); |
3832 v8::Local<v8::Value> r = script->Run(); | 3924 v8::Local<v8::Value> r = script->Run(); |
3833 | 3925 |
3834 CHECK(r->IsFunction()); | 3926 CHECK(r->IsFunction()); |
3835 CHECK_EQ(1, break_point_hit_count); | 3927 CHECK_EQ(1, break_point_hit_count); |
3836 | 3928 |
3837 // Get rid of the debug event listener. | 3929 // Get rid of the debug event listener. |
3838 v8::Debug::SetDebugEventListener2(NULL); | 3930 v8::Debug::SetDebugEventListener2(NULL); |
3839 CheckDebuggerUnloaded(); | 3931 CheckDebuggerUnloaded(); |
3840 } | 3932 } |
3841 | 3933 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3925 CHECK_EQ(0, uncaught_exception_hit_count); | 4017 CHECK_EQ(0, uncaught_exception_hit_count); |
3926 CHECK_EQ(0, message_callback_count); | 4018 CHECK_EQ(0, message_callback_count); |
3927 notCaught->Call(env->Global(), 0, NULL); | 4019 notCaught->Call(env->Global(), 0, NULL); |
3928 CHECK_EQ(2, exception_hit_count); | 4020 CHECK_EQ(2, exception_hit_count); |
3929 CHECK_EQ(1, uncaught_exception_hit_count); | 4021 CHECK_EQ(1, uncaught_exception_hit_count); |
3930 CHECK_EQ(1, message_callback_count); | 4022 CHECK_EQ(1, message_callback_count); |
3931 | 4023 |
3932 // No break on exception using JavaScript | 4024 // No break on exception using JavaScript |
3933 DebugEventCounterClear(); | 4025 DebugEventCounterClear(); |
3934 MessageCallbackCountClear(); | 4026 MessageCallbackCountClear(); |
3935 ChangeBreakOnExceptionFromJS(false, false); | 4027 ChangeBreakOnExceptionFromJS(env->GetIsolate(), false, false); |
3936 caught->Call(env->Global(), 0, NULL); | 4028 caught->Call(env->Global(), 0, NULL); |
3937 CHECK_EQ(0, exception_hit_count); | 4029 CHECK_EQ(0, exception_hit_count); |
3938 CHECK_EQ(0, uncaught_exception_hit_count); | 4030 CHECK_EQ(0, uncaught_exception_hit_count); |
3939 CHECK_EQ(0, message_callback_count); | 4031 CHECK_EQ(0, message_callback_count); |
3940 notCaught->Call(env->Global(), 0, NULL); | 4032 notCaught->Call(env->Global(), 0, NULL); |
3941 CHECK_EQ(0, exception_hit_count); | 4033 CHECK_EQ(0, exception_hit_count); |
3942 CHECK_EQ(0, uncaught_exception_hit_count); | 4034 CHECK_EQ(0, uncaught_exception_hit_count); |
3943 CHECK_EQ(1, message_callback_count); | 4035 CHECK_EQ(1, message_callback_count); |
3944 | 4036 |
3945 // Break on uncaught exception using JavaScript | 4037 // Break on uncaught exception using JavaScript |
3946 DebugEventCounterClear(); | 4038 DebugEventCounterClear(); |
3947 MessageCallbackCountClear(); | 4039 MessageCallbackCountClear(); |
3948 ChangeBreakOnExceptionFromJS(false, true); | 4040 ChangeBreakOnExceptionFromJS(env->GetIsolate(), false, true); |
3949 caught->Call(env->Global(), 0, NULL); | 4041 caught->Call(env->Global(), 0, NULL); |
3950 CHECK_EQ(0, exception_hit_count); | 4042 CHECK_EQ(0, exception_hit_count); |
3951 CHECK_EQ(0, uncaught_exception_hit_count); | 4043 CHECK_EQ(0, uncaught_exception_hit_count); |
3952 CHECK_EQ(0, message_callback_count); | 4044 CHECK_EQ(0, message_callback_count); |
3953 notCaught->Call(env->Global(), 0, NULL); | 4045 notCaught->Call(env->Global(), 0, NULL); |
3954 CHECK_EQ(1, exception_hit_count); | 4046 CHECK_EQ(1, exception_hit_count); |
3955 CHECK_EQ(1, uncaught_exception_hit_count); | 4047 CHECK_EQ(1, uncaught_exception_hit_count); |
3956 CHECK_EQ(1, message_callback_count); | 4048 CHECK_EQ(1, message_callback_count); |
3957 | 4049 |
3958 // Break on exception and uncaught exception using JavaScript | 4050 // Break on exception and uncaught exception using JavaScript |
3959 DebugEventCounterClear(); | 4051 DebugEventCounterClear(); |
3960 MessageCallbackCountClear(); | 4052 MessageCallbackCountClear(); |
3961 ChangeBreakOnExceptionFromJS(true, true); | 4053 ChangeBreakOnExceptionFromJS(env->GetIsolate(), true, true); |
3962 caught->Call(env->Global(), 0, NULL); | 4054 caught->Call(env->Global(), 0, NULL); |
3963 CHECK_EQ(1, exception_hit_count); | 4055 CHECK_EQ(1, exception_hit_count); |
3964 CHECK_EQ(0, message_callback_count); | 4056 CHECK_EQ(0, message_callback_count); |
3965 CHECK_EQ(0, uncaught_exception_hit_count); | 4057 CHECK_EQ(0, uncaught_exception_hit_count); |
3966 notCaught->Call(env->Global(), 0, NULL); | 4058 notCaught->Call(env->Global(), 0, NULL); |
3967 CHECK_EQ(2, exception_hit_count); | 4059 CHECK_EQ(2, exception_hit_count); |
3968 CHECK_EQ(1, uncaught_exception_hit_count); | 4060 CHECK_EQ(1, uncaught_exception_hit_count); |
3969 CHECK_EQ(1, message_callback_count); | 4061 CHECK_EQ(1, message_callback_count); |
3970 | 4062 |
3971 // Break on exception using JavaScript | 4063 // Break on exception using JavaScript |
3972 DebugEventCounterClear(); | 4064 DebugEventCounterClear(); |
3973 MessageCallbackCountClear(); | 4065 MessageCallbackCountClear(); |
3974 ChangeBreakOnExceptionFromJS(true, false); | 4066 ChangeBreakOnExceptionFromJS(env->GetIsolate(), true, false); |
3975 caught->Call(env->Global(), 0, NULL); | 4067 caught->Call(env->Global(), 0, NULL); |
3976 CHECK_EQ(1, exception_hit_count); | 4068 CHECK_EQ(1, exception_hit_count); |
3977 CHECK_EQ(0, uncaught_exception_hit_count); | 4069 CHECK_EQ(0, uncaught_exception_hit_count); |
3978 CHECK_EQ(0, message_callback_count); | 4070 CHECK_EQ(0, message_callback_count); |
3979 notCaught->Call(env->Global(), 0, NULL); | 4071 notCaught->Call(env->Global(), 0, NULL); |
3980 CHECK_EQ(2, exception_hit_count); | 4072 CHECK_EQ(2, exception_hit_count); |
3981 CHECK_EQ(1, uncaught_exception_hit_count); | 4073 CHECK_EQ(1, uncaught_exception_hit_count); |
3982 CHECK_EQ(1, message_callback_count); | 4074 CHECK_EQ(1, message_callback_count); |
3983 | 4075 |
3984 v8::Debug::SetDebugEventListener2(NULL); | 4076 v8::Debug::SetDebugEventListener2(NULL); |
(...skipping 23 matching lines...) Expand all Loading... |
4008 DebugEventCounterClear(); | 4100 DebugEventCounterClear(); |
4009 MessageCallbackCountClear(); | 4101 MessageCallbackCountClear(); |
4010 | 4102 |
4011 // Check initial state. | 4103 // Check initial state. |
4012 CHECK_EQ(0, exception_hit_count); | 4104 CHECK_EQ(0, exception_hit_count); |
4013 CHECK_EQ(0, uncaught_exception_hit_count); | 4105 CHECK_EQ(0, uncaught_exception_hit_count); |
4014 CHECK_EQ(0, message_callback_count); | 4106 CHECK_EQ(0, message_callback_count); |
4015 CHECK_EQ(-1, last_js_stack_height); | 4107 CHECK_EQ(-1, last_js_stack_height); |
4016 | 4108 |
4017 // Throws SyntaxError: Unexpected end of input | 4109 // Throws SyntaxError: Unexpected end of input |
4018 v8::Script::Compile(v8::String::New("+++")); | 4110 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "+++")); |
4019 CHECK_EQ(1, exception_hit_count); | 4111 CHECK_EQ(1, exception_hit_count); |
4020 CHECK_EQ(1, uncaught_exception_hit_count); | 4112 CHECK_EQ(1, uncaught_exception_hit_count); |
4021 CHECK_EQ(1, message_callback_count); | 4113 CHECK_EQ(1, message_callback_count); |
4022 CHECK_EQ(0, last_js_stack_height); // No JavaScript stack. | 4114 CHECK_EQ(0, last_js_stack_height); // No JavaScript stack. |
4023 | 4115 |
4024 // Throws SyntaxError: Unexpected identifier | 4116 // Throws SyntaxError: Unexpected identifier |
4025 v8::Script::Compile(v8::String::New("x x")); | 4117 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "x x")); |
4026 CHECK_EQ(2, exception_hit_count); | 4118 CHECK_EQ(2, exception_hit_count); |
4027 CHECK_EQ(2, uncaught_exception_hit_count); | 4119 CHECK_EQ(2, uncaught_exception_hit_count); |
4028 CHECK_EQ(2, message_callback_count); | 4120 CHECK_EQ(2, message_callback_count); |
4029 CHECK_EQ(0, last_js_stack_height); // No JavaScript stack. | 4121 CHECK_EQ(0, last_js_stack_height); // No JavaScript stack. |
4030 | 4122 |
4031 // Throws SyntaxError: Unexpected end of input | 4123 // Throws SyntaxError: Unexpected end of input |
4032 v8::Script::Compile(v8::String::New("eval('+++')"))->Run(); | 4124 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "eval('+++')")) |
| 4125 ->Run(); |
4033 CHECK_EQ(3, exception_hit_count); | 4126 CHECK_EQ(3, exception_hit_count); |
4034 CHECK_EQ(3, uncaught_exception_hit_count); | 4127 CHECK_EQ(3, uncaught_exception_hit_count); |
4035 CHECK_EQ(3, message_callback_count); | 4128 CHECK_EQ(3, message_callback_count); |
4036 CHECK_EQ(1, last_js_stack_height); | 4129 CHECK_EQ(1, last_js_stack_height); |
4037 | 4130 |
4038 // Throws SyntaxError: Unexpected identifier | 4131 // Throws SyntaxError: Unexpected identifier |
4039 v8::Script::Compile(v8::String::New("eval('x x')"))->Run(); | 4132 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "eval('x x')")) |
| 4133 ->Run(); |
4040 CHECK_EQ(4, exception_hit_count); | 4134 CHECK_EQ(4, exception_hit_count); |
4041 CHECK_EQ(4, uncaught_exception_hit_count); | 4135 CHECK_EQ(4, uncaught_exception_hit_count); |
4042 CHECK_EQ(4, message_callback_count); | 4136 CHECK_EQ(4, message_callback_count); |
4043 CHECK_EQ(1, last_js_stack_height); | 4137 CHECK_EQ(1, last_js_stack_height); |
4044 } | 4138 } |
4045 | 4139 |
4046 | 4140 |
4047 TEST(StepWithException) { | 4141 TEST(StepWithException) { |
4048 DebugLocalContext env; | 4142 DebugLocalContext env; |
4049 v8::HandleScope scope(env->GetIsolate()); | 4143 v8::HandleScope scope(env->GetIsolate()); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4256 CHECK_EQ(0, break_point_hit_count); | 4350 CHECK_EQ(0, break_point_hit_count); |
4257 | 4351 |
4258 // Get rid of the debug event listener. | 4352 // Get rid of the debug event listener. |
4259 v8::Debug::SetDebugEventListener2(NULL); | 4353 v8::Debug::SetDebugEventListener2(NULL); |
4260 CheckDebuggerUnloaded(); | 4354 CheckDebuggerUnloaded(); |
4261 } | 4355 } |
4262 | 4356 |
4263 | 4357 |
4264 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 4358 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
4265 v8::Handle<v8::Array> result = v8::Array::New(3); | 4359 v8::Handle<v8::Array> result = v8::Array::New(3); |
4266 result->Set(v8::Integer::New(0), v8::String::New("a")); | 4360 result->Set(v8::Integer::New(0), |
4267 result->Set(v8::Integer::New(1), v8::String::New("b")); | 4361 v8::String::NewFromUtf8(info.GetIsolate(), "a")); |
4268 result->Set(v8::Integer::New(2), v8::String::New("c")); | 4362 result->Set(v8::Integer::New(1), |
| 4363 v8::String::NewFromUtf8(info.GetIsolate(), "b")); |
| 4364 result->Set(v8::Integer::New(2), |
| 4365 v8::String::NewFromUtf8(info.GetIsolate(), "c")); |
4269 info.GetReturnValue().Set(result); | 4366 info.GetReturnValue().Set(result); |
4270 } | 4367 } |
4271 | 4368 |
4272 | 4369 |
4273 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 4370 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
4274 v8::Handle<v8::Array> result = v8::Array::New(2); | 4371 v8::Handle<v8::Array> result = v8::Array::New(2); |
4275 result->Set(v8::Integer::New(0), v8::Number::New(1)); | 4372 result->Set(v8::Integer::New(0), v8::Number::New(1)); |
4276 result->Set(v8::Integer::New(1), v8::Number::New(10)); | 4373 result->Set(v8::Integer::New(1), v8::Number::New(10)); |
4277 info.GetReturnValue().Set(result); | 4374 info.GetReturnValue().Set(result); |
4278 } | 4375 } |
4279 | 4376 |
4280 | 4377 |
4281 static void NamedGetter(v8::Local<v8::String> name, | 4378 static void NamedGetter(v8::Local<v8::String> name, |
4282 const v8::PropertyCallbackInfo<v8::Value>& info) { | 4379 const v8::PropertyCallbackInfo<v8::Value>& info) { |
4283 v8::String::Utf8Value n(name); | 4380 v8::String::Utf8Value n(name); |
4284 if (strcmp(*n, "a") == 0) { | 4381 if (strcmp(*n, "a") == 0) { |
4285 info.GetReturnValue().Set(v8::String::New("AA")); | 4382 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "AA")); |
4286 return; | 4383 return; |
4287 } else if (strcmp(*n, "b") == 0) { | 4384 } else if (strcmp(*n, "b") == 0) { |
4288 info.GetReturnValue().Set(v8::String::New("BB")); | 4385 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "BB")); |
4289 return; | 4386 return; |
4290 } else if (strcmp(*n, "c") == 0) { | 4387 } else if (strcmp(*n, "c") == 0) { |
4291 info.GetReturnValue().Set(v8::String::New("CC")); | 4388 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "CC")); |
4292 return; | 4389 return; |
4293 } else { | 4390 } else { |
4294 info.GetReturnValue().SetUndefined(); | 4391 info.GetReturnValue().SetUndefined(); |
4295 return; | 4392 return; |
4296 } | 4393 } |
4297 info.GetReturnValue().Set(name); | 4394 info.GetReturnValue().Set(name); |
4298 } | 4395 } |
4299 | 4396 |
4300 | 4397 |
4301 static void IndexedGetter(uint32_t index, | 4398 static void IndexedGetter(uint32_t index, |
4302 const v8::PropertyCallbackInfo<v8::Value>& info) { | 4399 const v8::PropertyCallbackInfo<v8::Value>& info) { |
4303 info.GetReturnValue().Set(static_cast<double>(index + 1)); | 4400 info.GetReturnValue().Set(static_cast<double>(index + 1)); |
4304 } | 4401 } |
4305 | 4402 |
4306 | 4403 |
4307 TEST(InterceptorPropertyMirror) { | 4404 TEST(InterceptorPropertyMirror) { |
4308 // Create a V8 environment with debug access. | 4405 // Create a V8 environment with debug access. |
4309 DebugLocalContext env; | 4406 DebugLocalContext env; |
4310 v8::HandleScope scope(env->GetIsolate()); | 4407 v8::HandleScope scope(env->GetIsolate()); |
4311 env.ExposeDebug(); | 4408 env.ExposeDebug(); |
4312 | 4409 |
4313 // Create object with named interceptor. | 4410 // Create object with named interceptor. |
4314 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); | 4411 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); |
4315 named->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); | 4412 named->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); |
4316 env->Global()->Set(v8::String::New("intercepted_named"), | 4413 env->Global()->Set( |
4317 named->NewInstance()); | 4414 v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_named"), |
| 4415 named->NewInstance()); |
4318 | 4416 |
4319 // Create object with indexed interceptor. | 4417 // Create object with indexed interceptor. |
4320 v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(); | 4418 v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(); |
4321 indexed->SetIndexedPropertyHandler(IndexedGetter, | 4419 indexed->SetIndexedPropertyHandler(IndexedGetter, |
4322 NULL, | 4420 NULL, |
4323 NULL, | 4421 NULL, |
4324 NULL, | 4422 NULL, |
4325 IndexedEnum); | 4423 IndexedEnum); |
4326 env->Global()->Set(v8::String::New("intercepted_indexed"), | 4424 env->Global()->Set( |
4327 indexed->NewInstance()); | 4425 v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_indexed"), |
| 4426 indexed->NewInstance()); |
4328 | 4427 |
4329 // Create object with both named and indexed interceptor. | 4428 // Create object with both named and indexed interceptor. |
4330 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(); | 4429 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(); |
4331 both->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); | 4430 both->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); |
4332 both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum); | 4431 both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum); |
4333 env->Global()->Set(v8::String::New("intercepted_both"), both->NewInstance()); | 4432 env->Global()->Set( |
| 4433 v8::String::NewFromUtf8(env->GetIsolate(), "intercepted_both"), |
| 4434 both->NewInstance()); |
4334 | 4435 |
4335 // Get mirrors for the three objects with interceptor. | 4436 // Get mirrors for the three objects with interceptor. |
4336 CompileRun( | 4437 CompileRun( |
4337 "var named_mirror = debug.MakeMirror(intercepted_named);" | 4438 "var named_mirror = debug.MakeMirror(intercepted_named);" |
4338 "var indexed_mirror = debug.MakeMirror(intercepted_indexed);" | 4439 "var indexed_mirror = debug.MakeMirror(intercepted_indexed);" |
4339 "var both_mirror = debug.MakeMirror(intercepted_both)"); | 4440 "var both_mirror = debug.MakeMirror(intercepted_both)"); |
4340 CHECK(CompileRun( | 4441 CHECK(CompileRun( |
4341 "named_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4442 "named_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4342 CHECK(CompileRun( | 4443 CHECK(CompileRun( |
4343 "indexed_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4444 "indexed_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4435 } | 4536 } |
4436 | 4537 |
4437 | 4538 |
4438 TEST(HiddenPrototypePropertyMirror) { | 4539 TEST(HiddenPrototypePropertyMirror) { |
4439 // Create a V8 environment with debug access. | 4540 // Create a V8 environment with debug access. |
4440 DebugLocalContext env; | 4541 DebugLocalContext env; |
4441 v8::HandleScope scope(env->GetIsolate()); | 4542 v8::HandleScope scope(env->GetIsolate()); |
4442 env.ExposeDebug(); | 4543 env.ExposeDebug(); |
4443 | 4544 |
4444 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); | 4545 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); |
4445 t0->InstanceTemplate()->Set(v8::String::New("x"), v8::Number::New(0)); | 4546 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "x"), |
| 4547 v8::Number::New(0)); |
4446 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 4548 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); |
4447 t1->SetHiddenPrototype(true); | 4549 t1->SetHiddenPrototype(true); |
4448 t1->InstanceTemplate()->Set(v8::String::New("y"), v8::Number::New(1)); | 4550 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "y"), |
| 4551 v8::Number::New(1)); |
4449 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); | 4552 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); |
4450 t2->SetHiddenPrototype(true); | 4553 t2->SetHiddenPrototype(true); |
4451 t2->InstanceTemplate()->Set(v8::String::New("z"), v8::Number::New(2)); | 4554 t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "z"), |
| 4555 v8::Number::New(2)); |
4452 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(); | 4556 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(); |
4453 t3->InstanceTemplate()->Set(v8::String::New("u"), v8::Number::New(3)); | 4557 t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "u"), |
| 4558 v8::Number::New(3)); |
4454 | 4559 |
4455 // Create object and set them on the global object. | 4560 // Create object and set them on the global object. |
4456 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance(); | 4561 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance(); |
4457 env->Global()->Set(v8::String::New("o0"), o0); | 4562 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o0"), o0); |
4458 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance(); | 4563 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance(); |
4459 env->Global()->Set(v8::String::New("o1"), o1); | 4564 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o1"), o1); |
4460 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance(); | 4565 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance(); |
4461 env->Global()->Set(v8::String::New("o2"), o2); | 4566 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o2"), o2); |
4462 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance(); | 4567 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance(); |
4463 env->Global()->Set(v8::String::New("o3"), o3); | 4568 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o3"), o3); |
4464 | 4569 |
4465 // Get mirrors for the four objects. | 4570 // Get mirrors for the four objects. |
4466 CompileRun( | 4571 CompileRun( |
4467 "var o0_mirror = debug.MakeMirror(o0);" | 4572 "var o0_mirror = debug.MakeMirror(o0);" |
4468 "var o1_mirror = debug.MakeMirror(o1);" | 4573 "var o1_mirror = debug.MakeMirror(o1);" |
4469 "var o2_mirror = debug.MakeMirror(o2);" | 4574 "var o2_mirror = debug.MakeMirror(o2);" |
4470 "var o3_mirror = debug.MakeMirror(o3)"); | 4575 "var o3_mirror = debug.MakeMirror(o3)"); |
4471 CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4576 CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4472 CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4577 CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4473 CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4578 CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4474 CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4579 CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4475 | 4580 |
4476 // Check that each object has one property. | 4581 // Check that each object has one property. |
4477 CHECK_EQ(1, CompileRun( | 4582 CHECK_EQ(1, CompileRun( |
4478 "o0_mirror.propertyNames().length")->Int32Value()); | 4583 "o0_mirror.propertyNames().length")->Int32Value()); |
4479 CHECK_EQ(1, CompileRun( | 4584 CHECK_EQ(1, CompileRun( |
4480 "o1_mirror.propertyNames().length")->Int32Value()); | 4585 "o1_mirror.propertyNames().length")->Int32Value()); |
4481 CHECK_EQ(1, CompileRun( | 4586 CHECK_EQ(1, CompileRun( |
4482 "o2_mirror.propertyNames().length")->Int32Value()); | 4587 "o2_mirror.propertyNames().length")->Int32Value()); |
4483 CHECK_EQ(1, CompileRun( | 4588 CHECK_EQ(1, CompileRun( |
4484 "o3_mirror.propertyNames().length")->Int32Value()); | 4589 "o3_mirror.propertyNames().length")->Int32Value()); |
4485 | 4590 |
4486 // Set o1 as prototype for o0. o1 has the hidden prototype flag so all | 4591 // Set o1 as prototype for o0. o1 has the hidden prototype flag so all |
4487 // properties on o1 should be seen on o0. | 4592 // properties on o1 should be seen on o0. |
4488 o0->Set(v8::String::New("__proto__"), o1); | 4593 o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o1); |
4489 CHECK_EQ(2, CompileRun( | 4594 CHECK_EQ(2, CompileRun( |
4490 "o0_mirror.propertyNames().length")->Int32Value()); | 4595 "o0_mirror.propertyNames().length")->Int32Value()); |
4491 CHECK_EQ(0, CompileRun( | 4596 CHECK_EQ(0, CompileRun( |
4492 "o0_mirror.property('x').value().value()")->Int32Value()); | 4597 "o0_mirror.property('x').value().value()")->Int32Value()); |
4493 CHECK_EQ(1, CompileRun( | 4598 CHECK_EQ(1, CompileRun( |
4494 "o0_mirror.property('y').value().value()")->Int32Value()); | 4599 "o0_mirror.property('y').value().value()")->Int32Value()); |
4495 | 4600 |
4496 // Set o2 as prototype for o0 (it will end up after o1 as o1 has the hidden | 4601 // Set o2 as prototype for o0 (it will end up after o1 as o1 has the hidden |
4497 // prototype flag. o2 also has the hidden prototype flag so all properties | 4602 // prototype flag. o2 also has the hidden prototype flag so all properties |
4498 // on o2 should be seen on o0 as well as properties on o1. | 4603 // on o2 should be seen on o0 as well as properties on o1. |
4499 o0->Set(v8::String::New("__proto__"), o2); | 4604 o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o2); |
4500 CHECK_EQ(3, CompileRun( | 4605 CHECK_EQ(3, CompileRun( |
4501 "o0_mirror.propertyNames().length")->Int32Value()); | 4606 "o0_mirror.propertyNames().length")->Int32Value()); |
4502 CHECK_EQ(0, CompileRun( | 4607 CHECK_EQ(0, CompileRun( |
4503 "o0_mirror.property('x').value().value()")->Int32Value()); | 4608 "o0_mirror.property('x').value().value()")->Int32Value()); |
4504 CHECK_EQ(1, CompileRun( | 4609 CHECK_EQ(1, CompileRun( |
4505 "o0_mirror.property('y').value().value()")->Int32Value()); | 4610 "o0_mirror.property('y').value().value()")->Int32Value()); |
4506 CHECK_EQ(2, CompileRun( | 4611 CHECK_EQ(2, CompileRun( |
4507 "o0_mirror.property('z').value().value()")->Int32Value()); | 4612 "o0_mirror.property('z').value().value()")->Int32Value()); |
4508 | 4613 |
4509 // Set o3 as prototype for o0 (it will end up after o1 and o2 as both o1 and | 4614 // Set o3 as prototype for o0 (it will end up after o1 and o2 as both o1 and |
4510 // o2 has the hidden prototype flag. o3 does not have the hidden prototype | 4615 // o2 has the hidden prototype flag. o3 does not have the hidden prototype |
4511 // flag so properties on o3 should not be seen on o0 whereas the properties | 4616 // flag so properties on o3 should not be seen on o0 whereas the properties |
4512 // from o1 and o2 should still be seen on o0. | 4617 // from o1 and o2 should still be seen on o0. |
4513 // Final prototype chain: o0 -> o1 -> o2 -> o3 | 4618 // Final prototype chain: o0 -> o1 -> o2 -> o3 |
4514 // Hidden prototypes: ^^ ^^ | 4619 // Hidden prototypes: ^^ ^^ |
4515 o0->Set(v8::String::New("__proto__"), o3); | 4620 o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o3); |
4516 CHECK_EQ(3, CompileRun( | 4621 CHECK_EQ(3, CompileRun( |
4517 "o0_mirror.propertyNames().length")->Int32Value()); | 4622 "o0_mirror.propertyNames().length")->Int32Value()); |
4518 CHECK_EQ(1, CompileRun( | 4623 CHECK_EQ(1, CompileRun( |
4519 "o3_mirror.propertyNames().length")->Int32Value()); | 4624 "o3_mirror.propertyNames().length")->Int32Value()); |
4520 CHECK_EQ(0, CompileRun( | 4625 CHECK_EQ(0, CompileRun( |
4521 "o0_mirror.property('x').value().value()")->Int32Value()); | 4626 "o0_mirror.property('x').value().value()")->Int32Value()); |
4522 CHECK_EQ(1, CompileRun( | 4627 CHECK_EQ(1, CompileRun( |
4523 "o0_mirror.property('y').value().value()")->Int32Value()); | 4628 "o0_mirror.property('y').value().value()")->Int32Value()); |
4524 CHECK_EQ(2, CompileRun( | 4629 CHECK_EQ(2, CompileRun( |
4525 "o0_mirror.property('z').value().value()")->Int32Value()); | 4630 "o0_mirror.property('z').value().value()")->Int32Value()); |
(...skipping 10 matching lines...) Expand all Loading... |
4536 info.GetReturnValue().Set(10); | 4641 info.GetReturnValue().Set(10); |
4537 } | 4642 } |
4538 | 4643 |
4539 | 4644 |
4540 TEST(NativeGetterPropertyMirror) { | 4645 TEST(NativeGetterPropertyMirror) { |
4541 // Create a V8 environment with debug access. | 4646 // Create a V8 environment with debug access. |
4542 DebugLocalContext env; | 4647 DebugLocalContext env; |
4543 v8::HandleScope scope(env->GetIsolate()); | 4648 v8::HandleScope scope(env->GetIsolate()); |
4544 env.ExposeDebug(); | 4649 env.ExposeDebug(); |
4545 | 4650 |
4546 v8::Handle<v8::String> name = v8::String::New("x"); | 4651 v8::Handle<v8::String> name = v8::String::NewFromUtf8(env->GetIsolate(), "x"); |
4547 // Create object with named accessor. | 4652 // Create object with named accessor. |
4548 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); | 4653 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); |
4549 named->SetAccessor(name, &ProtperyXNativeGetter, NULL, | 4654 named->SetAccessor(name, &ProtperyXNativeGetter, NULL, |
4550 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None); | 4655 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None); |
4551 | 4656 |
4552 // Create object with named property getter. | 4657 // Create object with named property getter. |
4553 env->Global()->Set(v8::String::New("instance"), named->NewInstance()); | 4658 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), |
| 4659 named->NewInstance()); |
4554 CHECK_EQ(10, CompileRun("instance.x")->Int32Value()); | 4660 CHECK_EQ(10, CompileRun("instance.x")->Int32Value()); |
4555 | 4661 |
4556 // Get mirror for the object with property getter. | 4662 // Get mirror for the object with property getter. |
4557 CompileRun("var instance_mirror = debug.MakeMirror(instance);"); | 4663 CompileRun("var instance_mirror = debug.MakeMirror(instance);"); |
4558 CHECK(CompileRun( | 4664 CHECK(CompileRun( |
4559 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4665 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4560 | 4666 |
4561 CompileRun("var named_names = instance_mirror.propertyNames();"); | 4667 CompileRun("var named_names = instance_mirror.propertyNames();"); |
4562 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); | 4668 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); |
4563 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); | 4669 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); |
(...skipping 10 matching lines...) Expand all Loading... |
4574 CompileRun("throw new Error('Error message');"); | 4680 CompileRun("throw new Error('Error message');"); |
4575 } | 4681 } |
4576 | 4682 |
4577 | 4683 |
4578 TEST(NativeGetterThrowingErrorPropertyMirror) { | 4684 TEST(NativeGetterThrowingErrorPropertyMirror) { |
4579 // Create a V8 environment with debug access. | 4685 // Create a V8 environment with debug access. |
4580 DebugLocalContext env; | 4686 DebugLocalContext env; |
4581 v8::HandleScope scope(env->GetIsolate()); | 4687 v8::HandleScope scope(env->GetIsolate()); |
4582 env.ExposeDebug(); | 4688 env.ExposeDebug(); |
4583 | 4689 |
4584 v8::Handle<v8::String> name = v8::String::New("x"); | 4690 v8::Handle<v8::String> name = v8::String::NewFromUtf8(env->GetIsolate(), "x"); |
4585 // Create object with named accessor. | 4691 // Create object with named accessor. |
4586 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); | 4692 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); |
4587 named->SetAccessor(name, &ProtperyXNativeGetterThrowingError, NULL, | 4693 named->SetAccessor(name, &ProtperyXNativeGetterThrowingError, NULL, |
4588 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None); | 4694 v8::Handle<v8::Value>(), v8::DEFAULT, v8::None); |
4589 | 4695 |
4590 // Create object with named property getter. | 4696 // Create object with named property getter. |
4591 env->Global()->Set(v8::String::New("instance"), named->NewInstance()); | 4697 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), |
| 4698 named->NewInstance()); |
4592 | 4699 |
4593 // Get mirror for the object with property getter. | 4700 // Get mirror for the object with property getter. |
4594 CompileRun("var instance_mirror = debug.MakeMirror(instance);"); | 4701 CompileRun("var instance_mirror = debug.MakeMirror(instance);"); |
4595 CHECK(CompileRun( | 4702 CHECK(CompileRun( |
4596 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4703 "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4597 CompileRun("named_names = instance_mirror.propertyNames();"); | 4704 CompileRun("named_names = instance_mirror.propertyNames();"); |
4598 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); | 4705 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); |
4599 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); | 4706 CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); |
4600 CHECK(CompileRun( | 4707 CHECK(CompileRun( |
4601 "instance_mirror.property('x').value().isError()")->BooleanValue()); | 4708 "instance_mirror.property('x').value().isError()")->BooleanValue()); |
4602 | 4709 |
4603 // Check that the message is that passed to the Error constructor. | 4710 // Check that the message is that passed to the Error constructor. |
4604 CHECK(CompileRun( | 4711 CHECK(CompileRun( |
4605 "instance_mirror.property('x').value().message() == 'Error message'")-> | 4712 "instance_mirror.property('x').value().message() == 'Error message'")-> |
4606 BooleanValue()); | 4713 BooleanValue()); |
4607 } | 4714 } |
4608 | 4715 |
4609 | 4716 |
4610 // Test that hidden properties object is not returned as an unnamed property | 4717 // Test that hidden properties object is not returned as an unnamed property |
4611 // among regular properties. | 4718 // among regular properties. |
4612 // See http://crbug.com/26491 | 4719 // See http://crbug.com/26491 |
4613 TEST(NoHiddenProperties) { | 4720 TEST(NoHiddenProperties) { |
4614 // Create a V8 environment with debug access. | 4721 // Create a V8 environment with debug access. |
4615 DebugLocalContext env; | 4722 DebugLocalContext env; |
4616 v8::HandleScope scope(env->GetIsolate()); | 4723 v8::HandleScope scope(env->GetIsolate()); |
4617 env.ExposeDebug(); | 4724 env.ExposeDebug(); |
4618 | 4725 |
4619 // Create an object in the global scope. | 4726 // Create an object in the global scope. |
4620 const char* source = "var obj = {a: 1};"; | 4727 const char* source = "var obj = {a: 1};"; |
4621 v8::Script::Compile(v8::String::New(source))->Run(); | 4728 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source)) |
| 4729 ->Run(); |
4622 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast( | 4730 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast( |
4623 env->Global()->Get(v8::String::New("obj"))); | 4731 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "obj"))); |
4624 // Set a hidden property on the object. | 4732 // Set a hidden property on the object. |
4625 obj->SetHiddenValue(v8::String::New("v8::test-debug::a"), | 4733 obj->SetHiddenValue( |
4626 v8::Int32::New(11)); | 4734 v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::a"), |
| 4735 v8::Int32::New(11)); |
4627 | 4736 |
4628 // Get mirror for the object with property getter. | 4737 // Get mirror for the object with property getter. |
4629 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); | 4738 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); |
4630 CHECK(CompileRun( | 4739 CHECK(CompileRun( |
4631 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4740 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4632 CompileRun("var named_names = obj_mirror.propertyNames();"); | 4741 CompileRun("var named_names = obj_mirror.propertyNames();"); |
4633 // There should be exactly one property. But there is also an unnamed | 4742 // There should be exactly one property. But there is also an unnamed |
4634 // property whose value is hidden properties dictionary. The latter | 4743 // property whose value is hidden properties dictionary. The latter |
4635 // property should not be in the list of reguar properties. | 4744 // property should not be in the list of reguar properties. |
4636 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); | 4745 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); |
4637 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue()); | 4746 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue()); |
4638 CHECK(CompileRun( | 4747 CHECK(CompileRun( |
4639 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); | 4748 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); |
4640 | 4749 |
4641 // Object created by t0 will become hidden prototype of object 'obj'. | 4750 // Object created by t0 will become hidden prototype of object 'obj'. |
4642 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); | 4751 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); |
4643 t0->InstanceTemplate()->Set(v8::String::New("b"), v8::Number::New(2)); | 4752 t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"), |
| 4753 v8::Number::New(2)); |
4644 t0->SetHiddenPrototype(true); | 4754 t0->SetHiddenPrototype(true); |
4645 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 4755 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); |
4646 t1->InstanceTemplate()->Set(v8::String::New("c"), v8::Number::New(3)); | 4756 t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "c"), |
| 4757 v8::Number::New(3)); |
4647 | 4758 |
4648 // Create proto objects, add hidden properties to them and set them on | 4759 // Create proto objects, add hidden properties to them and set them on |
4649 // the global object. | 4760 // the global object. |
4650 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance(); | 4761 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance(); |
4651 protoObj->SetHiddenValue(v8::String::New("v8::test-debug::b"), | 4762 protoObj->SetHiddenValue( |
4652 v8::Int32::New(12)); | 4763 v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::b"), |
4653 env->Global()->Set(v8::String::New("protoObj"), protoObj); | 4764 v8::Int32::New(12)); |
| 4765 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "protoObj"), |
| 4766 protoObj); |
4654 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance(); | 4767 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance(); |
4655 grandProtoObj->SetHiddenValue(v8::String::New("v8::test-debug::c"), | 4768 grandProtoObj->SetHiddenValue( |
4656 v8::Int32::New(13)); | 4769 v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::c"), |
4657 env->Global()->Set(v8::String::New("grandProtoObj"), grandProtoObj); | 4770 v8::Int32::New(13)); |
| 4771 env->Global()->Set( |
| 4772 v8::String::NewFromUtf8(env->GetIsolate(), "grandProtoObj"), |
| 4773 grandProtoObj); |
4658 | 4774 |
4659 // Setting prototypes: obj->protoObj->grandProtoObj | 4775 // Setting prototypes: obj->protoObj->grandProtoObj |
4660 protoObj->Set(v8::String::New("__proto__"), grandProtoObj); | 4776 protoObj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), |
4661 obj->Set(v8::String::New("__proto__"), protoObj); | 4777 grandProtoObj); |
| 4778 obj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), protoObj); |
4662 | 4779 |
4663 // Get mirror for the object with property getter. | 4780 // Get mirror for the object with property getter. |
4664 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); | 4781 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); |
4665 CHECK(CompileRun( | 4782 CHECK(CompileRun( |
4666 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); | 4783 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); |
4667 CompileRun("var named_names = obj_mirror.propertyNames();"); | 4784 CompileRun("var named_names = obj_mirror.propertyNames();"); |
4668 // There should be exactly two properties - one from the object itself and | 4785 // There should be exactly two properties - one from the object itself and |
4669 // another from its hidden prototype. | 4786 // another from its hidden prototype. |
4670 CHECK_EQ(2, CompileRun("named_names.length")->Int32Value()); | 4787 CHECK_EQ(2, CompileRun("named_names.length")->Int32Value()); |
4671 CHECK(CompileRun("named_names.sort(); named_names[0] == 'a' &&" | 4788 CHECK(CompileRun("named_names.sort(); named_names[0] == 'a' &&" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4837 class MessageQueueDebuggerThread : public v8::internal::Thread { | 4954 class MessageQueueDebuggerThread : public v8::internal::Thread { |
4838 public: | 4955 public: |
4839 MessageQueueDebuggerThread() | 4956 MessageQueueDebuggerThread() |
4840 : Thread("MessageQueueDebuggerThread") { } | 4957 : Thread("MessageQueueDebuggerThread") { } |
4841 void Run(); | 4958 void Run(); |
4842 }; | 4959 }; |
4843 | 4960 |
4844 | 4961 |
4845 static void MessageHandler(const v8::Debug::Message& message) { | 4962 static void MessageHandler(const v8::Debug::Message& message) { |
4846 v8::Handle<v8::String> json = message.GetJSON(); | 4963 v8::Handle<v8::String> json = message.GetJSON(); |
4847 v8::String::AsciiValue ascii(json); | 4964 v8::String::Utf8Value utf8(json); |
4848 if (IsBreakEventMessage(*ascii)) { | 4965 if (IsBreakEventMessage(*utf8)) { |
4849 // Lets test script wait until break occurs to send commands. | 4966 // Lets test script wait until break occurs to send commands. |
4850 // Signals when a break is reported. | 4967 // Signals when a break is reported. |
4851 message_queue_barriers.semaphore_2.Signal(); | 4968 message_queue_barriers.semaphore_2.Signal(); |
4852 } | 4969 } |
4853 | 4970 |
4854 // Allow message handler to block on a semaphore, to test queueing of | 4971 // Allow message handler to block on a semaphore, to test queueing of |
4855 // messages while blocked. | 4972 // messages while blocked. |
4856 message_queue_barriers.semaphore_1.Wait(); | 4973 message_queue_barriers.semaphore_1.Wait(); |
4857 } | 4974 } |
4858 | 4975 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5144 " }\n" | 5261 " }\n" |
5145 "}\n" | 5262 "}\n" |
5146 "\n" | 5263 "\n" |
5147 "foo();\n"; | 5264 "foo();\n"; |
5148 | 5265 |
5149 v8::Isolate::Scope isolate_scope(CcTest::isolate()); | 5266 v8::Isolate::Scope isolate_scope(CcTest::isolate()); |
5150 DebugLocalContext env; | 5267 DebugLocalContext env; |
5151 v8::HandleScope scope(env->GetIsolate()); | 5268 v8::HandleScope scope(env->GetIsolate()); |
5152 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler); | 5269 v8::Debug::SetMessageHandler2(&ThreadedMessageHandler); |
5153 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5270 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
5154 global_template->Set(v8::String::New("ThreadedAtBarrier1"), | 5271 global_template->Set( |
5155 v8::FunctionTemplate::New(ThreadedAtBarrier1)); | 5272 v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), |
| 5273 v8::FunctionTemplate::New(ThreadedAtBarrier1)); |
5156 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), | 5274 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), |
5157 NULL, | 5275 NULL, |
5158 global_template); | 5276 global_template); |
5159 v8::Context::Scope context_scope(context); | 5277 v8::Context::Scope context_scope(context); |
5160 | 5278 |
5161 CompileRun(source); | 5279 CompileRun(source); |
5162 } | 5280 } |
5163 | 5281 |
5164 | 5282 |
5165 void DebuggerThread::Run() { | 5283 void DebuggerThread::Run() { |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5477 CHECK_EQ(args[0]->Int32Value(), | 5595 CHECK_EQ(args[0]->Int32Value(), |
5478 v8::Debug::Call(frame_source_line)->Int32Value()); | 5596 v8::Debug::Call(frame_source_line)->Int32Value()); |
5479 } | 5597 } |
5480 | 5598 |
5481 | 5599 |
5482 // Function to test passing an additional parameter to a JavaScript function | 5600 // Function to test passing an additional parameter to a JavaScript function |
5483 // called in the debugger. It also tests that functions called in the debugger | 5601 // called in the debugger. It also tests that functions called in the debugger |
5484 // can throw exceptions. | 5602 // can throw exceptions. |
5485 static void CheckDataParameter( | 5603 static void CheckDataParameter( |
5486 const v8::FunctionCallbackInfo<v8::Value>& args) { | 5604 const v8::FunctionCallbackInfo<v8::Value>& args) { |
5487 v8::Handle<v8::String> data = v8::String::New("Test"); | 5605 v8::Handle<v8::String> data = |
| 5606 v8::String::NewFromUtf8(args.GetIsolate(), "Test"); |
5488 CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString()); | 5607 CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString()); |
5489 | 5608 |
5490 CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty()); | 5609 CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty()); |
5491 CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty()); | 5610 CHECK(v8::Debug::Call(debugger_call_with_data).IsEmpty()); |
5492 | 5611 |
5493 v8::TryCatch catcher; | 5612 v8::TryCatch catcher; |
5494 v8::Debug::Call(debugger_call_with_data); | 5613 v8::Debug::Call(debugger_call_with_data); |
5495 CHECK(catcher.HasCaught()); | 5614 CHECK(catcher.HasCaught()); |
5496 CHECK(catcher.Exception()->IsString()); | 5615 CHECK(catcher.Exception()->IsString()); |
5497 } | 5616 } |
5498 | 5617 |
5499 | 5618 |
5500 // Function to test using a JavaScript with closure in the debugger. | 5619 // Function to test using a JavaScript with closure in the debugger. |
5501 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) { | 5620 static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) { |
5502 CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber()); | 5621 CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber()); |
5503 CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value()); | 5622 CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value()); |
5504 } | 5623 } |
5505 | 5624 |
5506 | 5625 |
5507 // Test functions called through the debugger. | 5626 // Test functions called through the debugger. |
5508 TEST(CallFunctionInDebugger) { | 5627 TEST(CallFunctionInDebugger) { |
5509 // Create and enter a context with the functions CheckFrameCount, | 5628 // Create and enter a context with the functions CheckFrameCount, |
5510 // CheckSourceLine and CheckDataParameter installed. | 5629 // CheckSourceLine and CheckDataParameter installed. |
5511 v8::HandleScope scope(CcTest::isolate()); | 5630 v8::HandleScope scope(CcTest::isolate()); |
5512 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 5631 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
5513 global_template->Set(v8::String::New("CheckFrameCount"), | 5632 global_template->Set( |
5514 v8::FunctionTemplate::New(CheckFrameCount)); | 5633 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount"), |
5515 global_template->Set(v8::String::New("CheckSourceLine"), | 5634 v8::FunctionTemplate::New(CheckFrameCount)); |
5516 v8::FunctionTemplate::New(CheckSourceLine)); | 5635 global_template->Set( |
5517 global_template->Set(v8::String::New("CheckDataParameter"), | 5636 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine"), |
5518 v8::FunctionTemplate::New(CheckDataParameter)); | 5637 v8::FunctionTemplate::New(CheckSourceLine)); |
5519 global_template->Set(v8::String::New("CheckClosure"), | 5638 global_template->Set( |
5520 v8::FunctionTemplate::New(CheckClosure)); | 5639 v8::String::NewFromUtf8(CcTest::isolate(), "CheckDataParameter"), |
| 5640 v8::FunctionTemplate::New(CheckDataParameter)); |
| 5641 global_template->Set( |
| 5642 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure"), |
| 5643 v8::FunctionTemplate::New(CheckClosure)); |
5521 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), | 5644 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(), |
5522 NULL, | 5645 NULL, |
5523 global_template); | 5646 global_template); |
5524 v8::Context::Scope context_scope(context); | 5647 v8::Context::Scope context_scope(context); |
5525 | 5648 |
5526 // Compile a function for checking the number of JavaScript frames. | 5649 // Compile a function for checking the number of JavaScript frames. |
5527 v8::Script::Compile(v8::String::New(frame_count_source))->Run(); | 5650 v8::Script::Compile( |
5528 frame_count = v8::Local<v8::Function>::Cast( | 5651 v8::String::NewFromUtf8(CcTest::isolate(), frame_count_source))->Run(); |
5529 context->Global()->Get(v8::String::New("frame_count"))); | 5652 frame_count = v8::Local<v8::Function>::Cast(context->Global()->Get( |
| 5653 v8::String::NewFromUtf8(CcTest::isolate(), "frame_count"))); |
5530 | 5654 |
5531 // Compile a function for returning the source line for the top frame. | 5655 // Compile a function for returning the source line for the top frame. |
5532 v8::Script::Compile(v8::String::New(frame_source_line_source))->Run(); | 5656 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), |
5533 frame_source_line = v8::Local<v8::Function>::Cast( | 5657 frame_source_line_source))->Run(); |
5534 context->Global()->Get(v8::String::New("frame_source_line"))); | 5658 frame_source_line = v8::Local<v8::Function>::Cast(context->Global()->Get( |
| 5659 v8::String::NewFromUtf8(CcTest::isolate(), "frame_source_line"))); |
5535 | 5660 |
5536 // Compile a function returning the data parameter. | 5661 // Compile a function returning the data parameter. |
5537 v8::Script::Compile(v8::String::New(debugger_call_with_data_source))->Run(); | 5662 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), |
| 5663 debugger_call_with_data_source)) |
| 5664 ->Run(); |
5538 debugger_call_with_data = v8::Local<v8::Function>::Cast( | 5665 debugger_call_with_data = v8::Local<v8::Function>::Cast( |
5539 context->Global()->Get(v8::String::New("debugger_call_with_data"))); | 5666 context->Global()->Get(v8::String::NewFromUtf8( |
| 5667 CcTest::isolate(), "debugger_call_with_data"))); |
5540 | 5668 |
5541 // Compile a function capturing closure. | 5669 // Compile a function capturing closure. |
5542 debugger_call_with_closure = v8::Local<v8::Function>::Cast( | 5670 debugger_call_with_closure = |
5543 v8::Script::Compile( | 5671 v8::Local<v8::Function>::Cast(v8::Script::Compile( |
5544 v8::String::New(debugger_call_with_closure_source))->Run()); | 5672 v8::String::NewFromUtf8(CcTest::isolate(), |
| 5673 debugger_call_with_closure_source))->Run()); |
5545 | 5674 |
5546 // Calling a function through the debugger returns 0 frames if there are | 5675 // Calling a function through the debugger returns 0 frames if there are |
5547 // no JavaScript frames. | 5676 // no JavaScript frames. |
5548 CHECK_EQ(v8::Integer::New(0), v8::Debug::Call(frame_count)); | 5677 CHECK_EQ(v8::Integer::New(0), v8::Debug::Call(frame_count)); |
5549 | 5678 |
5550 // Test that the number of frames can be retrieved. | 5679 // Test that the number of frames can be retrieved. |
5551 v8::Script::Compile(v8::String::New("CheckFrameCount(1)"))->Run(); | 5680 v8::Script::Compile( |
5552 v8::Script::Compile(v8::String::New("function f() {" | 5681 v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount(1)"))->Run(); |
5553 " CheckFrameCount(2);" | 5682 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), |
5554 "}; f()"))->Run(); | 5683 "function f() {" |
| 5684 " CheckFrameCount(2);" |
| 5685 "}; f()"))->Run(); |
5555 | 5686 |
5556 // Test that the source line can be retrieved. | 5687 // Test that the source line can be retrieved. |
5557 v8::Script::Compile(v8::String::New("CheckSourceLine(0)"))->Run(); | 5688 v8::Script::Compile( |
5558 v8::Script::Compile(v8::String::New("function f() {\n" | 5689 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(0)"))->Run(); |
5559 " CheckSourceLine(1)\n" | 5690 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), |
5560 " CheckSourceLine(2)\n" | 5691 "function f() {\n" |
5561 " CheckSourceLine(3)\n" | 5692 " CheckSourceLine(1)\n" |
5562 "}; f()"))->Run(); | 5693 " CheckSourceLine(2)\n" |
| 5694 " CheckSourceLine(3)\n" |
| 5695 "}; f()"))->Run(); |
5563 | 5696 |
5564 // Test that a parameter can be passed to a function called in the debugger. | 5697 // Test that a parameter can be passed to a function called in the debugger. |
5565 v8::Script::Compile(v8::String::New("CheckDataParameter()"))->Run(); | 5698 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), |
| 5699 "CheckDataParameter()"))->Run(); |
5566 | 5700 |
5567 // Test that a function with closure can be run in the debugger. | 5701 // Test that a function with closure can be run in the debugger. |
5568 v8::Script::Compile(v8::String::New("CheckClosure()"))->Run(); | 5702 v8::Script::Compile( |
5569 | 5703 v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure()"))->Run(); |
5570 | 5704 |
5571 // Test that the source line is correct when there is a line offset. | 5705 // Test that the source line is correct when there is a line offset. |
5572 v8::ScriptOrigin origin(v8::String::New("test"), | 5706 v8::ScriptOrigin origin(v8::String::NewFromUtf8(CcTest::isolate(), "test"), |
5573 v8::Integer::New(7)); | 5707 v8::Integer::New(7)); |
5574 v8::Script::Compile(v8::String::New("CheckSourceLine(7)"), &origin)->Run(); | 5708 v8::Script::Compile( |
5575 v8::Script::Compile(v8::String::New("function f() {\n" | 5709 v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine(7)"), &origin) |
5576 " CheckSourceLine(8)\n" | 5710 ->Run(); |
5577 " CheckSourceLine(9)\n" | 5711 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), |
5578 " CheckSourceLine(10)\n" | 5712 "function f() {\n" |
5579 "}; f()"), &origin)->Run(); | 5713 " CheckSourceLine(8)\n" |
| 5714 " CheckSourceLine(9)\n" |
| 5715 " CheckSourceLine(10)\n" |
| 5716 "}; f()"), |
| 5717 &origin)->Run(); |
5580 } | 5718 } |
5581 | 5719 |
5582 | 5720 |
5583 // Debugger message handler which counts the number of breaks. | 5721 // Debugger message handler which counts the number of breaks. |
5584 static void SendContinueCommand(); | 5722 static void SendContinueCommand(); |
5585 static void MessageHandlerBreakPointHitCount( | 5723 static void MessageHandlerBreakPointHitCount( |
5586 const v8::Debug::Message& message) { | 5724 const v8::Debug::Message& message) { |
5587 if (message.IsEvent() && message.GetEvent() == v8::Break) { | 5725 if (message.IsEvent() && message.GetEvent() == v8::Break) { |
5588 // Count the number of breaks. | 5726 // Count the number of breaks. |
5589 break_point_hit_count++; | 5727 break_point_hit_count++; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5632 CheckDebuggerUnloaded(true); | 5770 CheckDebuggerUnloaded(true); |
5633 | 5771 |
5634 // Now set a debug message handler. | 5772 // Now set a debug message handler. |
5635 break_point_hit_count = 0; | 5773 break_point_hit_count = 0; |
5636 v8::Debug::SetMessageHandler2(MessageHandlerBreakPointHitCount); | 5774 v8::Debug::SetMessageHandler2(MessageHandlerBreakPointHitCount); |
5637 { | 5775 { |
5638 v8::HandleScope scope(env->GetIsolate()); | 5776 v8::HandleScope scope(env->GetIsolate()); |
5639 | 5777 |
5640 // Get the test functions again. | 5778 // Get the test functions again. |
5641 v8::Local<v8::Function> foo(v8::Local<v8::Function>::Cast( | 5779 v8::Local<v8::Function> foo(v8::Local<v8::Function>::Cast( |
5642 env->Global()->Get(v8::String::New("foo")))); | 5780 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "foo")))); |
5643 | 5781 |
5644 foo->Call(env->Global(), 0, NULL); | 5782 foo->Call(env->Global(), 0, NULL); |
5645 CHECK_EQ(0, break_point_hit_count); | 5783 CHECK_EQ(0, break_point_hit_count); |
5646 | 5784 |
5647 // Set break points and run again. | 5785 // Set break points and run again. |
5648 SetBreakPoint(foo, 0); | 5786 SetBreakPoint(foo, 0); |
5649 SetBreakPoint(foo, 4); | 5787 SetBreakPoint(foo, 4); |
5650 foo->Call(env->Global(), 0, NULL); | 5788 foo->Call(env->Global(), 0, NULL); |
5651 CHECK_EQ(2, break_point_hit_count); | 5789 CHECK_EQ(2, break_point_hit_count); |
5652 } | 5790 } |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6128 CompileRun( | 6266 CompileRun( |
6129 "var scripts = %DebugGetLoadedScripts();" | 6267 "var scripts = %DebugGetLoadedScripts();" |
6130 "var count = scripts.length;" | 6268 "var count = scripts.length;" |
6131 "for (var i = 0; i < count; ++i) {" | 6269 "for (var i = 0; i < count; ++i) {" |
6132 " scripts[i].line_ends;" | 6270 " scripts[i].line_ends;" |
6133 "}"); | 6271 "}"); |
6134 // Must not crash while accessing line_ends. | 6272 // Must not crash while accessing line_ends. |
6135 i::FLAG_allow_natives_syntax = allow_natives_syntax; | 6273 i::FLAG_allow_natives_syntax = allow_natives_syntax; |
6136 | 6274 |
6137 // Some scripts are retrieved - at least the number of native scripts. | 6275 // Some scripts are retrieved - at least the number of native scripts. |
6138 CHECK_GT((*env)->Global()->Get(v8::String::New("count"))->Int32Value(), 8); | 6276 CHECK_GT((*env) |
| 6277 ->Global() |
| 6278 ->Get(v8::String::NewFromUtf8(env->GetIsolate(), "count")) |
| 6279 ->Int32Value(), |
| 6280 8); |
6139 } | 6281 } |
6140 | 6282 |
6141 | 6283 |
6142 // Test script break points set on lines. | 6284 // Test script break points set on lines. |
6143 TEST(ScriptNameAndData) { | 6285 TEST(ScriptNameAndData) { |
6144 DebugLocalContext env; | 6286 DebugLocalContext env; |
6145 v8::HandleScope scope(env->GetIsolate()); | 6287 v8::HandleScope scope(env->GetIsolate()); |
6146 env.ExposeDebug(); | 6288 env.ExposeDebug(); |
6147 | 6289 |
6148 // Create functions for retrieving script name and data for the function on | 6290 // Create functions for retrieving script name and data for the function on |
6149 // the top frame when hitting a break point. | 6291 // the top frame when hitting a break point. |
6150 frame_script_name = CompileFunction(&env, | 6292 frame_script_name = CompileFunction(&env, |
6151 frame_script_name_source, | 6293 frame_script_name_source, |
6152 "frame_script_name"); | 6294 "frame_script_name"); |
6153 frame_script_data = CompileFunction(&env, | 6295 frame_script_data = CompileFunction(&env, |
6154 frame_script_data_source, | 6296 frame_script_data_source, |
6155 "frame_script_data"); | 6297 "frame_script_data"); |
6156 compiled_script_data = CompileFunction(&env, | 6298 compiled_script_data = CompileFunction(&env, |
6157 compiled_script_data_source, | 6299 compiled_script_data_source, |
6158 "compiled_script_data"); | 6300 "compiled_script_data"); |
6159 | 6301 |
6160 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); | 6302 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); |
6161 | 6303 |
6162 // Test function source. | 6304 // Test function source. |
6163 v8::Local<v8::String> script = v8::String::New( | 6305 v8::Local<v8::String> script = v8::String::NewFromUtf8(env->GetIsolate(), |
6164 "function f() {\n" | 6306 "function f() {\n" |
6165 " debugger;\n" | 6307 " debugger;\n" |
6166 "}\n"); | 6308 "}\n"); |
6167 | 6309 |
6168 v8::ScriptOrigin origin1 = v8::ScriptOrigin(v8::String::New("name")); | 6310 v8::ScriptOrigin origin1 = |
| 6311 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "name")); |
6169 v8::Handle<v8::Script> script1 = v8::Script::Compile(script, &origin1); | 6312 v8::Handle<v8::Script> script1 = v8::Script::Compile(script, &origin1); |
6170 script1->SetData(v8::String::New("data")); | 6313 script1->SetData(v8::String::NewFromUtf8(env->GetIsolate(), "data")); |
6171 script1->Run(); | 6314 script1->Run(); |
6172 v8::Local<v8::Function> f; | 6315 v8::Local<v8::Function> f; |
6173 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 6316 f = v8::Local<v8::Function>::Cast( |
| 6317 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
6174 | 6318 |
6175 f->Call(env->Global(), 0, NULL); | 6319 f->Call(env->Global(), 0, NULL); |
6176 CHECK_EQ(1, break_point_hit_count); | 6320 CHECK_EQ(1, break_point_hit_count); |
6177 CHECK_EQ("name", last_script_name_hit); | 6321 CHECK_EQ("name", last_script_name_hit); |
6178 CHECK_EQ("data", last_script_data_hit); | 6322 CHECK_EQ("data", last_script_data_hit); |
6179 | 6323 |
6180 // Compile the same script again without setting data. As the compilation | 6324 // Compile the same script again without setting data. As the compilation |
6181 // cache is disabled when debugging expect the data to be missing. | 6325 // cache is disabled when debugging expect the data to be missing. |
6182 v8::Script::Compile(script, &origin1)->Run(); | 6326 v8::Script::Compile(script, &origin1)->Run(); |
6183 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 6327 f = v8::Local<v8::Function>::Cast( |
| 6328 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
6184 f->Call(env->Global(), 0, NULL); | 6329 f->Call(env->Global(), 0, NULL); |
6185 CHECK_EQ(2, break_point_hit_count); | 6330 CHECK_EQ(2, break_point_hit_count); |
6186 CHECK_EQ("name", last_script_name_hit); | 6331 CHECK_EQ("name", last_script_name_hit); |
6187 CHECK_EQ("", last_script_data_hit); // Undefined results in empty string. | 6332 CHECK_EQ("", last_script_data_hit); // Undefined results in empty string. |
6188 | 6333 |
6189 v8::Local<v8::String> data_obj_source = v8::String::New( | 6334 v8::Local<v8::String> data_obj_source = v8::String::NewFromUtf8( |
6190 "({ a: 'abc',\n" | 6335 env->GetIsolate(), |
6191 " b: 123,\n" | 6336 "({ a: 'abc',\n" |
6192 " toString: function() { return this.a + ' ' + this.b; }\n" | 6337 " b: 123,\n" |
6193 "})\n"); | 6338 " toString: function() { return this.a + ' ' + this.b; }\n" |
| 6339 "})\n"); |
6194 v8::Local<v8::Value> data_obj = v8::Script::Compile(data_obj_source)->Run(); | 6340 v8::Local<v8::Value> data_obj = v8::Script::Compile(data_obj_source)->Run(); |
6195 v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name")); | 6341 v8::ScriptOrigin origin2 = |
| 6342 v8::ScriptOrigin(v8::String::NewFromUtf8(env->GetIsolate(), "new name")); |
6196 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); | 6343 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); |
6197 script2->Run(); | 6344 script2->Run(); |
6198 script2->SetData(data_obj->ToString()); | 6345 script2->SetData(data_obj->ToString()); |
6199 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 6346 f = v8::Local<v8::Function>::Cast( |
| 6347 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
6200 f->Call(env->Global(), 0, NULL); | 6348 f->Call(env->Global(), 0, NULL); |
6201 CHECK_EQ(3, break_point_hit_count); | 6349 CHECK_EQ(3, break_point_hit_count); |
6202 CHECK_EQ("new name", last_script_name_hit); | 6350 CHECK_EQ("new name", last_script_name_hit); |
6203 CHECK_EQ("abc 123", last_script_data_hit); | 6351 CHECK_EQ("abc 123", last_script_data_hit); |
6204 | 6352 |
6205 v8::Handle<v8::Script> script3 = | 6353 v8::Handle<v8::Script> script3 = v8::Script::Compile( |
6206 v8::Script::Compile(script, &origin2, NULL, | 6354 script, &origin2, NULL, |
6207 v8::String::New("in compile")); | 6355 v8::String::NewFromUtf8(env->GetIsolate(), "in compile")); |
6208 CHECK_EQ("in compile", last_script_data_hit); | 6356 CHECK_EQ("in compile", last_script_data_hit); |
6209 script3->Run(); | 6357 script3->Run(); |
6210 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 6358 f = v8::Local<v8::Function>::Cast( |
| 6359 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
6211 f->Call(env->Global(), 0, NULL); | 6360 f->Call(env->Global(), 0, NULL); |
6212 CHECK_EQ(4, break_point_hit_count); | 6361 CHECK_EQ(4, break_point_hit_count); |
6213 CHECK_EQ("in compile", last_script_data_hit); | 6362 CHECK_EQ("in compile", last_script_data_hit); |
6214 } | 6363 } |
6215 | 6364 |
6216 | 6365 |
6217 static v8::Handle<v8::Context> expected_context; | 6366 static v8::Handle<v8::Context> expected_context; |
6218 static v8::Handle<v8::Value> expected_context_data; | 6367 static v8::Handle<v8::Value> expected_context_data; |
6219 | 6368 |
6220 | 6369 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6252 context_1 = v8::Context::New(isolate, NULL, global_template, global_object); | 6401 context_1 = v8::Context::New(isolate, NULL, global_template, global_object); |
6253 context_2 = v8::Context::New(isolate, NULL, global_template, global_object); | 6402 context_2 = v8::Context::New(isolate, NULL, global_template, global_object); |
6254 | 6403 |
6255 v8::Debug::SetMessageHandler2(ContextCheckMessageHandler); | 6404 v8::Debug::SetMessageHandler2(ContextCheckMessageHandler); |
6256 | 6405 |
6257 // Default data value is undefined. | 6406 // Default data value is undefined. |
6258 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); | 6407 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); |
6259 CHECK(context_2->GetEmbedderData(0)->IsUndefined()); | 6408 CHECK(context_2->GetEmbedderData(0)->IsUndefined()); |
6260 | 6409 |
6261 // Set and check different data values. | 6410 // Set and check different data values. |
6262 v8::Handle<v8::String> data_1 = v8::String::New("1"); | 6411 v8::Handle<v8::String> data_1 = v8::String::NewFromUtf8(isolate, "1"); |
6263 v8::Handle<v8::String> data_2 = v8::String::New("2"); | 6412 v8::Handle<v8::String> data_2 = v8::String::NewFromUtf8(isolate, "2"); |
6264 context_1->SetEmbedderData(0, data_1); | 6413 context_1->SetEmbedderData(0, data_1); |
6265 context_2->SetEmbedderData(0, data_2); | 6414 context_2->SetEmbedderData(0, data_2); |
6266 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); | 6415 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); |
6267 CHECK(context_2->GetEmbedderData(0)->StrictEquals(data_2)); | 6416 CHECK(context_2->GetEmbedderData(0)->StrictEquals(data_2)); |
6268 | 6417 |
6269 // Simple test function which causes a break. | 6418 // Simple test function which causes a break. |
6270 const char* source = "function f() { debugger; }"; | 6419 const char* source = "function f() { debugger; }"; |
6271 | 6420 |
6272 // Enter and run function in the first context. | 6421 // Enter and run function in the first context. |
6273 { | 6422 { |
6274 v8::Context::Scope context_scope(context_1); | 6423 v8::Context::Scope context_scope(context_1); |
6275 expected_context = context_1; | 6424 expected_context = context_1; |
6276 expected_context_data = data_1; | 6425 expected_context_data = data_1; |
6277 v8::Local<v8::Function> f = CompileFunction(source, "f"); | 6426 v8::Local<v8::Function> f = CompileFunction(isolate, source, "f"); |
6278 f->Call(context_1->Global(), 0, NULL); | 6427 f->Call(context_1->Global(), 0, NULL); |
6279 } | 6428 } |
6280 | 6429 |
6281 | 6430 |
6282 // Enter and run function in the second context. | 6431 // Enter and run function in the second context. |
6283 { | 6432 { |
6284 v8::Context::Scope context_scope(context_2); | 6433 v8::Context::Scope context_scope(context_2); |
6285 expected_context = context_2; | 6434 expected_context = context_2; |
6286 expected_context_data = data_2; | 6435 expected_context_data = data_2; |
6287 v8::Local<v8::Function> f = CompileFunction(source, "f"); | 6436 v8::Local<v8::Function> f = CompileFunction(isolate, source, "f"); |
6288 f->Call(context_2->Global(), 0, NULL); | 6437 f->Call(context_2->Global(), 0, NULL); |
6289 } | 6438 } |
6290 | 6439 |
6291 // Two times compile event and two times break event. | 6440 // Two times compile event and two times break event. |
6292 CHECK_GT(message_handler_hit_count, 4); | 6441 CHECK_GT(message_handler_hit_count, 4); |
6293 | 6442 |
6294 v8::Debug::SetMessageHandler2(NULL); | 6443 v8::Debug::SetMessageHandler2(NULL); |
6295 CheckDebuggerUnloaded(); | 6444 CheckDebuggerUnloaded(); |
6296 } | 6445 } |
6297 | 6446 |
(...skipping 20 matching lines...) Expand all Loading... |
6318 // Test that a debug break can be scheduled while in a message handler. | 6467 // Test that a debug break can be scheduled while in a message handler. |
6319 TEST(DebugBreakInMessageHandler) { | 6468 TEST(DebugBreakInMessageHandler) { |
6320 DebugLocalContext env; | 6469 DebugLocalContext env; |
6321 v8::HandleScope scope(env->GetIsolate()); | 6470 v8::HandleScope scope(env->GetIsolate()); |
6322 | 6471 |
6323 v8::Debug::SetMessageHandler2(DebugBreakMessageHandler); | 6472 v8::Debug::SetMessageHandler2(DebugBreakMessageHandler); |
6324 | 6473 |
6325 // Test functions. | 6474 // Test functions. |
6326 const char* script = "function f() { debugger; g(); } function g() { }"; | 6475 const char* script = "function f() { debugger; g(); } function g() { }"; |
6327 CompileRun(script); | 6476 CompileRun(script); |
6328 v8::Local<v8::Function> f = | 6477 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
6329 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 6478 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
6330 v8::Local<v8::Function> g = | 6479 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( |
6331 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("g"))); | 6480 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "g"))); |
6332 | 6481 |
6333 // Call f then g. The debugger statement in f will casue a break which will | 6482 // Call f then g. The debugger statement in f will casue a break which will |
6334 // cause another break. | 6483 // cause another break. |
6335 f->Call(env->Global(), 0, NULL); | 6484 f->Call(env->Global(), 0, NULL); |
6336 CHECK_EQ(2, message_handler_break_hit_count); | 6485 CHECK_EQ(2, message_handler_break_hit_count); |
6337 // Calling g will not cause any additional breaks. | 6486 // Calling g will not cause any additional breaks. |
6338 g->Call(env->Global(), 0, NULL); | 6487 g->Call(env->Global(), 0, NULL); |
6339 CHECK_EQ(2, message_handler_break_hit_count); | 6488 CHECK_EQ(2, message_handler_break_hit_count); |
6340 } | 6489 } |
6341 | 6490 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6384 frame_function_name = CompileFunction(&env, | 6533 frame_function_name = CompileFunction(&env, |
6385 frame_function_name_source, | 6534 frame_function_name_source, |
6386 "frame_function_name"); | 6535 "frame_function_name"); |
6387 | 6536 |
6388 // Test RegExp which matches white spaces and comments at the begining of a | 6537 // Test RegExp which matches white spaces and comments at the begining of a |
6389 // source line. | 6538 // source line. |
6390 const char* script = | 6539 const char* script = |
6391 "var sourceLineBeginningSkip = /^(?:[ \\v\\h]*(?:\\/\\*.*?\\*\\/)*)*/;\n" | 6540 "var sourceLineBeginningSkip = /^(?:[ \\v\\h]*(?:\\/\\*.*?\\*\\/)*)*/;\n" |
6392 "function f(s) { return s.match(sourceLineBeginningSkip)[0].length; }"; | 6541 "function f(s) { return s.match(sourceLineBeginningSkip)[0].length; }"; |
6393 | 6542 |
6394 v8::Local<v8::Function> f = CompileFunction(script, "f"); | 6543 v8::Local<v8::Function> f = CompileFunction(env->GetIsolate(), script, "f"); |
6395 const int argc = 1; | 6544 const int argc = 1; |
6396 v8::Handle<v8::Value> argv[argc] = { v8::String::New(" /* xxx */ a=0;") }; | 6545 v8::Handle<v8::Value> argv[argc] = { |
| 6546 v8::String::NewFromUtf8(env->GetIsolate(), " /* xxx */ a=0;")}; |
6397 v8::Local<v8::Value> result = f->Call(env->Global(), argc, argv); | 6547 v8::Local<v8::Value> result = f->Call(env->Global(), argc, argv); |
6398 CHECK_EQ(12, result->Int32Value()); | 6548 CHECK_EQ(12, result->Int32Value()); |
6399 | 6549 |
6400 v8::Debug::SetDebugEventListener2(DebugEventDebugBreak); | 6550 v8::Debug::SetDebugEventListener2(DebugEventDebugBreak); |
6401 v8::Debug::DebugBreak(env->GetIsolate()); | 6551 v8::Debug::DebugBreak(env->GetIsolate()); |
6402 result = f->Call(env->Global(), argc, argv); | 6552 result = f->Call(env->Global(), argc, argv); |
6403 | 6553 |
6404 // Check that there was only one break event. Matching RegExp should not | 6554 // Check that there was only one break event. Matching RegExp should not |
6405 // cause Break events. | 6555 // cause Break events. |
6406 CHECK_EQ(1, break_point_hit_count); | 6556 CHECK_EQ(1, break_point_hit_count); |
(...skipping 11 matching lines...) Expand all Loading... |
6418 v8::Handle<v8::ObjectTemplate>(); | 6568 v8::Handle<v8::ObjectTemplate>(); |
6419 context_1 = | 6569 context_1 = |
6420 v8::Context::New(CcTest::isolate(), NULL, global_template); | 6570 v8::Context::New(CcTest::isolate(), NULL, global_template); |
6421 | 6571 |
6422 v8::Debug::SetMessageHandler2(message_handler); | 6572 v8::Debug::SetMessageHandler2(message_handler); |
6423 | 6573 |
6424 // Default data value is undefined. | 6574 // Default data value is undefined. |
6425 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); | 6575 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); |
6426 | 6576 |
6427 // Set and check a data value. | 6577 // Set and check a data value. |
6428 v8::Handle<v8::String> data_1 = v8::String::New("1"); | 6578 v8::Handle<v8::String> data_1 = |
| 6579 v8::String::NewFromUtf8(CcTest::isolate(), "1"); |
6429 context_1->SetEmbedderData(0, data_1); | 6580 context_1->SetEmbedderData(0, data_1); |
6430 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); | 6581 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); |
6431 | 6582 |
6432 // Simple test function with eval that causes a break. | 6583 // Simple test function with eval that causes a break. |
6433 const char* source = "function f() { eval('debugger;'); }"; | 6584 const char* source = "function f() { eval('debugger;'); }"; |
6434 | 6585 |
6435 // Enter and run function in the context. | 6586 // Enter and run function in the context. |
6436 { | 6587 { |
6437 v8::Context::Scope context_scope(context_1); | 6588 v8::Context::Scope context_scope(context_1); |
6438 expected_context = context_1; | 6589 expected_context = context_1; |
6439 expected_context_data = data_1; | 6590 expected_context_data = data_1; |
6440 v8::Local<v8::Function> f = CompileFunction(source, "f"); | 6591 v8::Local<v8::Function> f = CompileFunction(CcTest::isolate(), source, "f"); |
6441 f->Call(context_1->Global(), 0, NULL); | 6592 f->Call(context_1->Global(), 0, NULL); |
6442 } | 6593 } |
6443 | 6594 |
6444 v8::Debug::SetMessageHandler2(NULL); | 6595 v8::Debug::SetMessageHandler2(NULL); |
6445 } | 6596 } |
6446 | 6597 |
6447 | 6598 |
6448 // Test which creates a context and sets embedder data on it. Checks that this | 6599 // Test which creates a context and sets embedder data on it. Checks that this |
6449 // data is set correctly and that when the debug message handler is called for | 6600 // data is set correctly and that when the debug message handler is called for |
6450 // break event in an eval statement the expected context is the one returned by | 6601 // break event in an eval statement the expected context is the one returned by |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6551 // Request the loaded scripts to initialize the debugger script cache. | 6702 // Request the loaded scripts to initialize the debugger script cache. |
6552 debug->GetLoadedScripts(); | 6703 debug->GetLoadedScripts(); |
6553 | 6704 |
6554 // Do garbage collection to ensure that only the script in this test will be | 6705 // Do garbage collection to ensure that only the script in this test will be |
6555 // collected afterwards. | 6706 // collected afterwards. |
6556 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 6707 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
6557 | 6708 |
6558 script_collected_count = 0; | 6709 script_collected_count = 0; |
6559 v8::Debug::SetDebugEventListener2(DebugEventScriptCollectedEvent); | 6710 v8::Debug::SetDebugEventListener2(DebugEventScriptCollectedEvent); |
6560 { | 6711 { |
6561 v8::Script::Compile(v8::String::New("eval('a=1')"))->Run(); | 6712 v8::Script::Compile( |
6562 v8::Script::Compile(v8::String::New("eval('a=2')"))->Run(); | 6713 v8::String::NewFromUtf8(env->GetIsolate(), "eval('a=1')"))->Run(); |
| 6714 v8::Script::Compile( |
| 6715 v8::String::NewFromUtf8(env->GetIsolate(), "eval('a=2')"))->Run(); |
6563 } | 6716 } |
6564 | 6717 |
6565 // Do garbage collection to collect the script above which is no longer | 6718 // Do garbage collection to collect the script above which is no longer |
6566 // referenced. | 6719 // referenced. |
6567 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 6720 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
6568 | 6721 |
6569 CHECK_EQ(2, script_collected_count); | 6722 CHECK_EQ(2, script_collected_count); |
6570 | 6723 |
6571 v8::Debug::SetDebugEventListener2(NULL); | 6724 v8::Debug::SetDebugEventListener2(NULL); |
6572 CheckDebuggerUnloaded(); | 6725 CheckDebuggerUnloaded(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6611 } | 6764 } |
6612 | 6765 |
6613 // Request the loaded scripts to initialize the debugger script cache. | 6766 // Request the loaded scripts to initialize the debugger script cache. |
6614 debug->GetLoadedScripts(); | 6767 debug->GetLoadedScripts(); |
6615 | 6768 |
6616 // Do garbage collection to ensure that only the script in this test will be | 6769 // Do garbage collection to ensure that only the script in this test will be |
6617 // collected afterwards. | 6770 // collected afterwards. |
6618 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 6771 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
6619 | 6772 |
6620 v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler); | 6773 v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler); |
6621 v8::Script::Compile(v8::String::New("eval('a=1')"))->Run(); | 6774 v8::Script::Compile(v8::String::NewFromUtf8(isolate, "eval('a=1')"))->Run(); |
6622 v8::Script::Compile(v8::String::New("eval('a=2')"))->Run(); | 6775 v8::Script::Compile(v8::String::NewFromUtf8(isolate, "eval('a=2')"))->Run(); |
6623 | 6776 |
6624 // Leave context | 6777 // Leave context |
6625 { | 6778 { |
6626 v8::HandleScope scope(isolate); | 6779 v8::HandleScope scope(isolate); |
6627 v8::Local<v8::Context> local_context = | 6780 v8::Local<v8::Context> local_context = |
6628 v8::Local<v8::Context>::New(isolate, context); | 6781 v8::Local<v8::Context>::New(isolate, context); |
6629 local_context->Exit(); | 6782 local_context->Exit(); |
6630 } | 6783 } |
6631 context.Dispose(); | 6784 context.Reset(); |
6632 | 6785 |
6633 // Do garbage collection to collect the script above which is no longer | 6786 // Do garbage collection to collect the script above which is no longer |
6634 // referenced. | 6787 // referenced. |
6635 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 6788 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
6636 | 6789 |
6637 CHECK_EQ(2, script_collected_message_count); | 6790 CHECK_EQ(2, script_collected_message_count); |
6638 | 6791 |
6639 v8::Debug::SetMessageHandler2(NULL); | 6792 v8::Debug::SetMessageHandler2(NULL); |
6640 } | 6793 } |
6641 | 6794 |
(...skipping 14 matching lines...) Expand all Loading... |
6656 | 6809 |
6657 // Tests that after compile event is sent as many times as there are scripts | 6810 // Tests that after compile event is sent as many times as there are scripts |
6658 // compiled. | 6811 // compiled. |
6659 TEST(AfterCompileMessageWhenMessageHandlerIsReset) { | 6812 TEST(AfterCompileMessageWhenMessageHandlerIsReset) { |
6660 DebugLocalContext env; | 6813 DebugLocalContext env; |
6661 v8::HandleScope scope(env->GetIsolate()); | 6814 v8::HandleScope scope(env->GetIsolate()); |
6662 after_compile_message_count = 0; | 6815 after_compile_message_count = 0; |
6663 const char* script = "var a=1"; | 6816 const char* script = "var a=1"; |
6664 | 6817 |
6665 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); | 6818 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); |
6666 v8::Script::Compile(v8::String::New(script))->Run(); | 6819 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script)) |
| 6820 ->Run(); |
6667 v8::Debug::SetMessageHandler2(NULL); | 6821 v8::Debug::SetMessageHandler2(NULL); |
6668 | 6822 |
6669 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); | 6823 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); |
6670 v8::Debug::DebugBreak(env->GetIsolate()); | 6824 v8::Debug::DebugBreak(env->GetIsolate()); |
6671 v8::Script::Compile(v8::String::New(script))->Run(); | 6825 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script)) |
| 6826 ->Run(); |
6672 | 6827 |
6673 // Setting listener to NULL should cause debugger unload. | 6828 // Setting listener to NULL should cause debugger unload. |
6674 v8::Debug::SetMessageHandler2(NULL); | 6829 v8::Debug::SetMessageHandler2(NULL); |
6675 CheckDebuggerUnloaded(); | 6830 CheckDebuggerUnloaded(); |
6676 | 6831 |
6677 // Compilation cache should be disabled when debugger is active. | 6832 // Compilation cache should be disabled when debugger is active. |
6678 CHECK_EQ(2, after_compile_message_count); | 6833 CHECK_EQ(2, after_compile_message_count); |
6679 } | 6834 } |
6680 | 6835 |
6681 | 6836 |
6682 // Tests that break event is sent when message handler is reset. | 6837 // Tests that break event is sent when message handler is reset. |
6683 TEST(BreakMessageWhenMessageHandlerIsReset) { | 6838 TEST(BreakMessageWhenMessageHandlerIsReset) { |
6684 DebugLocalContext env; | 6839 DebugLocalContext env; |
6685 v8::HandleScope scope(env->GetIsolate()); | 6840 v8::HandleScope scope(env->GetIsolate()); |
6686 after_compile_message_count = 0; | 6841 after_compile_message_count = 0; |
6687 const char* script = "function f() {};"; | 6842 const char* script = "function f() {};"; |
6688 | 6843 |
6689 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); | 6844 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); |
6690 v8::Script::Compile(v8::String::New(script))->Run(); | 6845 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script)) |
| 6846 ->Run(); |
6691 v8::Debug::SetMessageHandler2(NULL); | 6847 v8::Debug::SetMessageHandler2(NULL); |
6692 | 6848 |
6693 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); | 6849 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); |
6694 v8::Debug::DebugBreak(env->GetIsolate()); | 6850 v8::Debug::DebugBreak(env->GetIsolate()); |
6695 v8::Local<v8::Function> f = | 6851 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
6696 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 6852 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
6697 f->Call(env->Global(), 0, NULL); | 6853 f->Call(env->Global(), 0, NULL); |
6698 | 6854 |
6699 // Setting message handler to NULL should cause debugger unload. | 6855 // Setting message handler to NULL should cause debugger unload. |
6700 v8::Debug::SetMessageHandler2(NULL); | 6856 v8::Debug::SetMessageHandler2(NULL); |
6701 CheckDebuggerUnloaded(); | 6857 CheckDebuggerUnloaded(); |
6702 | 6858 |
6703 // Compilation cache should be disabled when debugger is active. | 6859 // Compilation cache should be disabled when debugger is active. |
6704 CHECK_EQ(1, after_compile_message_count); | 6860 CHECK_EQ(1, after_compile_message_count); |
6705 } | 6861 } |
6706 | 6862 |
(...skipping 12 matching lines...) Expand all Loading... |
6719 DebugLocalContext env; | 6875 DebugLocalContext env; |
6720 v8::HandleScope scope(env->GetIsolate()); | 6876 v8::HandleScope scope(env->GetIsolate()); |
6721 | 6877 |
6722 // For this test, we want to break on uncaught exceptions: | 6878 // For this test, we want to break on uncaught exceptions: |
6723 ChangeBreakOnException(false, true); | 6879 ChangeBreakOnException(false, true); |
6724 | 6880 |
6725 exception_event_count = 0; | 6881 exception_event_count = 0; |
6726 const char* script = "function f() {throw new Error()};"; | 6882 const char* script = "function f() {throw new Error()};"; |
6727 | 6883 |
6728 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); | 6884 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); |
6729 v8::Script::Compile(v8::String::New(script))->Run(); | 6885 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script)) |
| 6886 ->Run(); |
6730 v8::Debug::SetMessageHandler2(NULL); | 6887 v8::Debug::SetMessageHandler2(NULL); |
6731 | 6888 |
6732 v8::Debug::SetMessageHandler2(ExceptionMessageHandler); | 6889 v8::Debug::SetMessageHandler2(ExceptionMessageHandler); |
6733 v8::Local<v8::Function> f = | 6890 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( |
6734 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 6891 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); |
6735 f->Call(env->Global(), 0, NULL); | 6892 f->Call(env->Global(), 0, NULL); |
6736 | 6893 |
6737 // Setting message handler to NULL should cause debugger unload. | 6894 // Setting message handler to NULL should cause debugger unload. |
6738 v8::Debug::SetMessageHandler2(NULL); | 6895 v8::Debug::SetMessageHandler2(NULL); |
6739 CheckDebuggerUnloaded(); | 6896 CheckDebuggerUnloaded(); |
6740 | 6897 |
6741 CHECK_EQ(1, exception_event_count); | 6898 CHECK_EQ(1, exception_event_count); |
6742 } | 6899 } |
6743 | 6900 |
6744 | 6901 |
6745 // Tests after compile event is sent when there are some provisional | 6902 // Tests after compile event is sent when there are some provisional |
6746 // breakpoints out of the scripts lines range. | 6903 // breakpoints out of the scripts lines range. |
6747 TEST(ProvisionalBreakpointOnLineOutOfRange) { | 6904 TEST(ProvisionalBreakpointOnLineOutOfRange) { |
6748 DebugLocalContext env; | 6905 DebugLocalContext env; |
6749 v8::HandleScope scope(env->GetIsolate()); | 6906 v8::HandleScope scope(env->GetIsolate()); |
6750 env.ExposeDebug(); | 6907 env.ExposeDebug(); |
6751 const char* script = "function f() {};"; | 6908 const char* script = "function f() {};"; |
6752 const char* resource_name = "test_resource"; | 6909 const char* resource_name = "test_resource"; |
6753 | 6910 |
6754 // Set a couple of provisional breakpoint on lines out of the script lines | 6911 // Set a couple of provisional breakpoint on lines out of the script lines |
6755 // range. | 6912 // range. |
6756 int sbp1 = SetScriptBreakPointByNameFromJS(resource_name, 3, | 6913 int sbp1 = SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, |
6757 -1 /* no column */); | 6914 3, -1 /* no column */); |
6758 int sbp2 = SetScriptBreakPointByNameFromJS(resource_name, 5, 5); | 6915 int sbp2 = |
| 6916 SetScriptBreakPointByNameFromJS(env->GetIsolate(), resource_name, 5, 5); |
6759 | 6917 |
6760 after_compile_message_count = 0; | 6918 after_compile_message_count = 0; |
6761 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); | 6919 v8::Debug::SetMessageHandler2(AfterCompileMessageHandler); |
6762 | 6920 |
6763 v8::ScriptOrigin origin( | 6921 v8::ScriptOrigin origin( |
6764 v8::String::New(resource_name), | 6922 v8::String::NewFromUtf8(env->GetIsolate(), resource_name), |
6765 v8::Integer::New(10), | 6923 v8::Integer::New(10), |
6766 v8::Integer::New(1)); | 6924 v8::Integer::New(1)); |
6767 // Compile a script whose first line number is greater than the breakpoints' | 6925 // Compile a script whose first line number is greater than the breakpoints' |
6768 // lines. | 6926 // lines. |
6769 v8::Script::Compile(v8::String::New(script), &origin)->Run(); | 6927 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script), |
| 6928 &origin)->Run(); |
6770 | 6929 |
6771 // If the script is compiled successfully there is exactly one after compile | 6930 // If the script is compiled successfully there is exactly one after compile |
6772 // event. In case of an exception in debugger code after compile event is not | 6931 // event. In case of an exception in debugger code after compile event is not |
6773 // sent. | 6932 // sent. |
6774 CHECK_EQ(1, after_compile_message_count); | 6933 CHECK_EQ(1, after_compile_message_count); |
6775 | 6934 |
6776 ClearBreakPointFromJS(sbp1); | 6935 ClearBreakPointFromJS(env->GetIsolate(), sbp1); |
6777 ClearBreakPointFromJS(sbp2); | 6936 ClearBreakPointFromJS(env->GetIsolate(), sbp2); |
6778 v8::Debug::SetMessageHandler2(NULL); | 6937 v8::Debug::SetMessageHandler2(NULL); |
6779 } | 6938 } |
6780 | 6939 |
6781 | 6940 |
6782 static void BreakMessageHandler(const v8::Debug::Message& message) { | 6941 static void BreakMessageHandler(const v8::Debug::Message& message) { |
6783 i::Isolate* isolate = CcTest::i_isolate(); | 6942 i::Isolate* isolate = CcTest::i_isolate(); |
6784 if (message.IsEvent() && message.GetEvent() == v8::Break) { | 6943 if (message.IsEvent() && message.GetEvent() == v8::Break) { |
6785 // Count the number of breaks. | 6944 // Count the number of breaks. |
6786 break_point_hit_count++; | 6945 break_point_hit_count++; |
6787 | 6946 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6925 // Check backtrace from ProcessDebugMessages. | 7084 // Check backtrace from ProcessDebugMessages. |
6926 BacktraceData::frame_counter = -10; | 7085 BacktraceData::frame_counter = -10; |
6927 v8::Debug::SendCommand( | 7086 v8::Debug::SendCommand( |
6928 isolate, | 7087 isolate, |
6929 buffer, | 7088 buffer, |
6930 AsciiToUtf16(scripts_command, buffer), | 7089 AsciiToUtf16(scripts_command, buffer), |
6931 NULL); | 7090 NULL); |
6932 v8::Debug::ProcessDebugMessages(); | 7091 v8::Debug::ProcessDebugMessages(); |
6933 CHECK_EQ(BacktraceData::frame_counter, 0); | 7092 CHECK_EQ(BacktraceData::frame_counter, 0); |
6934 | 7093 |
6935 v8::Handle<v8::String> void0 = v8::String::New("void(0)"); | 7094 v8::Handle<v8::String> void0 = |
| 7095 v8::String::NewFromUtf8(env->GetIsolate(), "void(0)"); |
6936 v8::Handle<v8::Script> script = v8::Script::Compile(void0, void0); | 7096 v8::Handle<v8::Script> script = v8::Script::Compile(void0, void0); |
6937 | 7097 |
6938 // Check backtrace from "void(0)" script. | 7098 // Check backtrace from "void(0)" script. |
6939 BacktraceData::frame_counter = -10; | 7099 BacktraceData::frame_counter = -10; |
6940 v8::Debug::SendCommand( | 7100 v8::Debug::SendCommand( |
6941 isolate, | 7101 isolate, |
6942 buffer, | 7102 buffer, |
6943 AsciiToUtf16(scripts_command, buffer), | 7103 AsciiToUtf16(scripts_command, buffer), |
6944 NULL); | 7104 NULL); |
6945 script->Run(); | 7105 script->Run(); |
6946 CHECK_EQ(BacktraceData::frame_counter, 1); | 7106 CHECK_EQ(BacktraceData::frame_counter, 1); |
6947 | 7107 |
6948 // Get rid of the debug message handler. | 7108 // Get rid of the debug message handler. |
6949 v8::Debug::SetMessageHandler2(NULL); | 7109 v8::Debug::SetMessageHandler2(NULL); |
6950 CheckDebuggerUnloaded(); | 7110 CheckDebuggerUnloaded(); |
6951 } | 7111 } |
6952 | 7112 |
6953 | 7113 |
6954 TEST(GetMirror) { | 7114 TEST(GetMirror) { |
6955 DebugLocalContext env; | 7115 DebugLocalContext env; |
6956 v8::HandleScope scope(env->GetIsolate()); | 7116 v8::HandleScope scope(env->GetIsolate()); |
6957 v8::Handle<v8::Value> obj = v8::Debug::GetMirror(v8::String::New("hodja")); | 7117 v8::Handle<v8::Value> obj = |
6958 v8::Handle<v8::Function> run_test = v8::Handle<v8::Function>::Cast( | 7118 v8::Debug::GetMirror(v8::String::NewFromUtf8(env->GetIsolate(), "hodja")); |
6959 v8::Script::New( | 7119 v8::Handle<v8::Function> run_test = |
6960 v8::String::New( | 7120 v8::Handle<v8::Function>::Cast(v8::Script::New( |
| 7121 v8::String::NewFromUtf8( |
| 7122 env->GetIsolate(), |
6961 "function runTest(mirror) {" | 7123 "function runTest(mirror) {" |
6962 " return mirror.isString() && (mirror.length() == 5);" | 7124 " return mirror.isString() && (mirror.length() == 5);" |
6963 "}" | 7125 "}" |
6964 "" | 7126 "" |
6965 "runTest;"))->Run()); | 7127 "runTest;"))->Run()); |
6966 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj); | 7128 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj); |
6967 CHECK(result->IsTrue()); | 7129 CHECK(result->IsTrue()); |
6968 } | 7130 } |
6969 | 7131 |
6970 | 7132 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7051 v8::HandleScope scope(env->GetIsolate()); | 7213 v8::HandleScope scope(env->GetIsolate()); |
7052 env.ExposeDebug(); | 7214 env.ExposeDebug(); |
7053 | 7215 |
7054 // Save handles to the debugger and debugee contexts to be used in | 7216 // Save handles to the debugger and debugee contexts to be used in |
7055 // NamedGetterWithCallingContextCheck. | 7217 // NamedGetterWithCallingContextCheck. |
7056 debugee_context = env.context(); | 7218 debugee_context = env.context(); |
7057 debugger_context = v8::Utils::ToLocal(debug->debug_context()); | 7219 debugger_context = v8::Utils::ToLocal(debug->debug_context()); |
7058 | 7220 |
7059 // Create object with 'a' property accessor. | 7221 // Create object with 'a' property accessor. |
7060 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); | 7222 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); |
7061 named->SetAccessor(v8::String::New("a"), | 7223 named->SetAccessor(v8::String::NewFromUtf8(env->GetIsolate(), "a"), |
7062 NamedGetterWithCallingContextCheck); | 7224 NamedGetterWithCallingContextCheck); |
7063 env->Global()->Set(v8::String::New("obj"), | 7225 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "obj"), |
7064 named->NewInstance()); | 7226 named->NewInstance()); |
7065 | 7227 |
7066 // Register the debug event listener | 7228 // Register the debug event listener |
7067 v8::Debug::SetDebugEventListener2(DebugEventGetAtgumentPropertyValue); | 7229 v8::Debug::SetDebugEventListener2(DebugEventGetAtgumentPropertyValue); |
7068 | 7230 |
7069 // Create a function that invokes debugger. | 7231 // Create a function that invokes debugger. |
7070 v8::Local<v8::Function> foo = CompileFunction( | 7232 v8::Local<v8::Function> foo = CompileFunction( |
7071 &env, | 7233 &env, |
7072 "function bar(x) { debugger; }" | 7234 "function bar(x) { debugger; }" |
7073 "function foo(){ bar(obj); }", | 7235 "function foo(){ bar(obj); }", |
(...skipping 27 matching lines...) Expand all Loading... |
7101 | 7263 |
7102 // Check that event details contain context where debug event occured. | 7264 // Check that event details contain context where debug event occured. |
7103 TEST(DebugEventContext) { | 7265 TEST(DebugEventContext) { |
7104 v8::Isolate* isolate = CcTest::isolate(); | 7266 v8::Isolate* isolate = CcTest::isolate(); |
7105 v8::HandleScope scope(isolate); | 7267 v8::HandleScope scope(isolate); |
7106 expected_callback_data = v8::Int32::New(2010); | 7268 expected_callback_data = v8::Int32::New(2010); |
7107 expected_context = v8::Context::New(isolate); | 7269 expected_context = v8::Context::New(isolate); |
7108 v8::Debug::SetDebugEventListener2(DebugEventContextChecker, | 7270 v8::Debug::SetDebugEventListener2(DebugEventContextChecker, |
7109 expected_callback_data); | 7271 expected_callback_data); |
7110 v8::Context::Scope context_scope(expected_context); | 7272 v8::Context::Scope context_scope(expected_context); |
7111 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run(); | 7273 v8::Script::Compile( |
| 7274 v8::String::NewFromUtf8(isolate, "(function(){debugger;})();"))->Run(); |
7112 expected_context.Clear(); | 7275 expected_context.Clear(); |
7113 v8::Debug::SetDebugEventListener2(NULL); | 7276 v8::Debug::SetDebugEventListener2(NULL); |
7114 expected_context_data = v8::Handle<v8::Value>(); | 7277 expected_context_data = v8::Handle<v8::Value>(); |
7115 CheckDebuggerUnloaded(); | 7278 CheckDebuggerUnloaded(); |
7116 } | 7279 } |
7117 | 7280 |
7118 | 7281 |
7119 static void* expected_break_data; | 7282 static void* expected_break_data; |
7120 static bool was_debug_break_called; | 7283 static bool was_debug_break_called; |
7121 static bool was_debug_event_called; | 7284 static bool was_debug_event_called; |
(...skipping 14 matching lines...) Expand all Loading... |
7136 v8::HandleScope scope(isolate); | 7299 v8::HandleScope scope(isolate); |
7137 v8::Debug::SetDebugEventListener2(DebugEventBreakDataChecker); | 7300 v8::Debug::SetDebugEventListener2(DebugEventBreakDataChecker); |
7138 | 7301 |
7139 TestClientData::constructor_call_counter = 0; | 7302 TestClientData::constructor_call_counter = 0; |
7140 TestClientData::destructor_call_counter = 0; | 7303 TestClientData::destructor_call_counter = 0; |
7141 | 7304 |
7142 expected_break_data = NULL; | 7305 expected_break_data = NULL; |
7143 was_debug_event_called = false; | 7306 was_debug_event_called = false; |
7144 was_debug_break_called = false; | 7307 was_debug_break_called = false; |
7145 v8::Debug::DebugBreakForCommand(NULL, isolate); | 7308 v8::Debug::DebugBreakForCommand(NULL, isolate); |
7146 v8::Script::Compile(v8::String::New("(function(x){return x;})(1);"))->Run(); | 7309 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
| 7310 "(function(x){return x;})(1);")) |
| 7311 ->Run(); |
7147 CHECK(was_debug_event_called); | 7312 CHECK(was_debug_event_called); |
7148 CHECK(!was_debug_break_called); | 7313 CHECK(!was_debug_break_called); |
7149 | 7314 |
7150 TestClientData* data1 = new TestClientData(); | 7315 TestClientData* data1 = new TestClientData(); |
7151 expected_break_data = data1; | 7316 expected_break_data = data1; |
7152 was_debug_event_called = false; | 7317 was_debug_event_called = false; |
7153 was_debug_break_called = false; | 7318 was_debug_break_called = false; |
7154 v8::Debug::DebugBreakForCommand(data1, isolate); | 7319 v8::Debug::DebugBreakForCommand(data1, isolate); |
7155 v8::Script::Compile(v8::String::New("(function(x){return x+1;})(1);"))->Run(); | 7320 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
| 7321 "(function(x){return x+1;})(1);")) |
| 7322 ->Run(); |
7156 CHECK(was_debug_event_called); | 7323 CHECK(was_debug_event_called); |
7157 CHECK(!was_debug_break_called); | 7324 CHECK(!was_debug_break_called); |
7158 | 7325 |
7159 expected_break_data = NULL; | 7326 expected_break_data = NULL; |
7160 was_debug_event_called = false; | 7327 was_debug_event_called = false; |
7161 was_debug_break_called = false; | 7328 was_debug_break_called = false; |
7162 v8::Debug::DebugBreak(isolate); | 7329 v8::Debug::DebugBreak(isolate); |
7163 v8::Script::Compile(v8::String::New("(function(x){return x+2;})(1);"))->Run(); | 7330 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
| 7331 "(function(x){return x+2;})(1);")) |
| 7332 ->Run(); |
7164 CHECK(!was_debug_event_called); | 7333 CHECK(!was_debug_event_called); |
7165 CHECK(was_debug_break_called); | 7334 CHECK(was_debug_break_called); |
7166 | 7335 |
7167 TestClientData* data2 = new TestClientData(); | 7336 TestClientData* data2 = new TestClientData(); |
7168 expected_break_data = data2; | 7337 expected_break_data = data2; |
7169 was_debug_event_called = false; | 7338 was_debug_event_called = false; |
7170 was_debug_break_called = false; | 7339 was_debug_break_called = false; |
7171 v8::Debug::DebugBreak(isolate); | 7340 v8::Debug::DebugBreak(isolate); |
7172 v8::Debug::DebugBreakForCommand(data2, isolate); | 7341 v8::Debug::DebugBreakForCommand(data2, isolate); |
7173 v8::Script::Compile(v8::String::New("(function(x){return x+3;})(1);"))->Run(); | 7342 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), |
| 7343 "(function(x){return x+3;})(1);")) |
| 7344 ->Run(); |
7174 CHECK(was_debug_event_called); | 7345 CHECK(was_debug_event_called); |
7175 CHECK(was_debug_break_called); | 7346 CHECK(was_debug_break_called); |
7176 | 7347 |
7177 CHECK_EQ(2, TestClientData::constructor_call_counter); | 7348 CHECK_EQ(2, TestClientData::constructor_call_counter); |
7178 CHECK_EQ(TestClientData::constructor_call_counter, | 7349 CHECK_EQ(TestClientData::constructor_call_counter, |
7179 TestClientData::destructor_call_counter); | 7350 TestClientData::destructor_call_counter); |
7180 | 7351 |
7181 v8::Debug::SetDebugEventListener2(NULL); | 7352 v8::Debug::SetDebugEventListener2(NULL); |
7182 CheckDebuggerUnloaded(); | 7353 CheckDebuggerUnloaded(); |
7183 } | 7354 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7226 | 7397 |
7227 | 7398 |
7228 // Set a debug event listener which will keep interrupting execution until | 7399 // Set a debug event listener which will keep interrupting execution until |
7229 // debug break. When inside function bar it will deoptimize all functions. | 7400 // debug break. When inside function bar it will deoptimize all functions. |
7230 // This tests lazy deoptimization bailout for the stack check, as the first | 7401 // This tests lazy deoptimization bailout for the stack check, as the first |
7231 // time in function bar when using debug break and no break points will be at | 7402 // time in function bar when using debug break and no break points will be at |
7232 // the initial stack check. | 7403 // the initial stack check. |
7233 v8::Debug::SetDebugEventListener2(DebugEventBreakDeoptimize); | 7404 v8::Debug::SetDebugEventListener2(DebugEventBreakDeoptimize); |
7234 | 7405 |
7235 // Compile and run function bar which will optimize it for some flag settings. | 7406 // Compile and run function bar which will optimize it for some flag settings. |
7236 v8::Script::Compile(v8::String::New("function bar(){}; bar()"))->Run(); | 7407 v8::Script::Compile(v8::String::NewFromUtf8( |
| 7408 env->GetIsolate(), "function bar(){}; bar()"))->Run(); |
7237 | 7409 |
7238 // Set debug break and call bar again. | 7410 // Set debug break and call bar again. |
7239 v8::Debug::DebugBreak(env->GetIsolate()); | 7411 v8::Debug::DebugBreak(env->GetIsolate()); |
7240 v8::Script::Compile(v8::String::New("bar()"))->Run(); | 7412 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "bar()")) |
| 7413 ->Run(); |
7241 | 7414 |
7242 CHECK(debug_event_break_deoptimize_done); | 7415 CHECK(debug_event_break_deoptimize_done); |
7243 | 7416 |
7244 v8::Debug::SetDebugEventListener2(NULL); | 7417 v8::Debug::SetDebugEventListener2(NULL); |
7245 } | 7418 } |
7246 | 7419 |
7247 | 7420 |
7248 static void DebugEventBreakWithOptimizedStack( | 7421 static void DebugEventBreakWithOptimizedStack( |
7249 const v8::Debug::EventDetails& event_details) { | 7422 const v8::Debug::EventDetails& event_details) { |
| 7423 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); |
7250 v8::DebugEvent event = event_details.GetEvent(); | 7424 v8::DebugEvent event = event_details.GetEvent(); |
7251 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); | 7425 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); |
7252 if (event == v8::Break) { | 7426 if (event == v8::Break) { |
7253 if (!frame_function_name.IsEmpty()) { | 7427 if (!frame_function_name.IsEmpty()) { |
7254 for (int i = 0; i < 2; i++) { | 7428 for (int i = 0; i < 2; i++) { |
7255 const int argc = 2; | 7429 const int argc = 2; |
7256 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(i) }; | 7430 v8::Handle<v8::Value> argv[argc] = { exec_state, v8::Integer::New(i) }; |
7257 // Get the name of the function in frame i. | 7431 // Get the name of the function in frame i. |
7258 v8::Handle<v8::Value> result = | 7432 v8::Handle<v8::Value> result = |
7259 frame_function_name->Call(exec_state, argc, argv); | 7433 frame_function_name->Call(exec_state, argc, argv); |
7260 CHECK(result->IsString()); | 7434 CHECK(result->IsString()); |
7261 v8::Handle<v8::String> function_name(result->ToString()); | 7435 v8::Handle<v8::String> function_name(result->ToString()); |
7262 CHECK(function_name->Equals(v8::String::New("loop"))); | 7436 CHECK(function_name->Equals(v8::String::NewFromUtf8(isolate, "loop"))); |
7263 // Get the name of the first argument in frame i. | 7437 // Get the name of the first argument in frame i. |
7264 result = frame_argument_name->Call(exec_state, argc, argv); | 7438 result = frame_argument_name->Call(exec_state, argc, argv); |
7265 CHECK(result->IsString()); | 7439 CHECK(result->IsString()); |
7266 v8::Handle<v8::String> argument_name(result->ToString()); | 7440 v8::Handle<v8::String> argument_name(result->ToString()); |
7267 CHECK(argument_name->Equals(v8::String::New("count"))); | 7441 CHECK(argument_name->Equals(v8::String::NewFromUtf8(isolate, "count"))); |
7268 // Get the value of the first argument in frame i. If the | 7442 // Get the value of the first argument in frame i. If the |
7269 // funtion is optimized the value will be undefined, otherwise | 7443 // funtion is optimized the value will be undefined, otherwise |
7270 // the value will be '1 - i'. | 7444 // the value will be '1 - i'. |
7271 // | 7445 // |
7272 // TODO(3141533): We should be able to get the real value for | 7446 // TODO(3141533): We should be able to get the real value for |
7273 // optimized frames. | 7447 // optimized frames. |
7274 result = frame_argument_value->Call(exec_state, argc, argv); | 7448 result = frame_argument_value->Call(exec_state, argc, argv); |
7275 CHECK(result->IsUndefined() || (result->Int32Value() == 1 - i)); | 7449 CHECK(result->IsUndefined() || (result->Int32Value() == 1 - i)); |
7276 // Get the name of the first local variable. | 7450 // Get the name of the first local variable. |
7277 result = frame_local_name->Call(exec_state, argc, argv); | 7451 result = frame_local_name->Call(exec_state, argc, argv); |
7278 CHECK(result->IsString()); | 7452 CHECK(result->IsString()); |
7279 v8::Handle<v8::String> local_name(result->ToString()); | 7453 v8::Handle<v8::String> local_name(result->ToString()); |
7280 CHECK(local_name->Equals(v8::String::New("local"))); | 7454 CHECK(local_name->Equals(v8::String::NewFromUtf8(isolate, "local"))); |
7281 // Get the value of the first local variable. If the function | 7455 // Get the value of the first local variable. If the function |
7282 // is optimized the value will be undefined, otherwise it will | 7456 // is optimized the value will be undefined, otherwise it will |
7283 // be 42. | 7457 // be 42. |
7284 // | 7458 // |
7285 // TODO(3141533): We should be able to get the real value for | 7459 // TODO(3141533): We should be able to get the real value for |
7286 // optimized frames. | 7460 // optimized frames. |
7287 result = frame_local_value->Call(exec_state, argc, argv); | 7461 result = frame_local_value->Call(exec_state, argc, argv); |
7288 CHECK(result->IsUndefined() || (result->Int32Value() == 42)); | 7462 CHECK(result->IsUndefined() || (result->Int32Value() == 42)); |
7289 } | 7463 } |
7290 } | 7464 } |
(...skipping 28 matching lines...) Expand all Loading... |
7319 v8::Handle<v8::Function> schedule_break = | 7493 v8::Handle<v8::Function> schedule_break = |
7320 schedule_break_template->GetFunction(); | 7494 schedule_break_template->GetFunction(); |
7321 env->Global()->Set(v8_str("scheduleBreak"), schedule_break); | 7495 env->Global()->Set(v8_str("scheduleBreak"), schedule_break); |
7322 | 7496 |
7323 const char* src = | 7497 const char* src = |
7324 "function loop(count) {" | 7498 "function loop(count) {" |
7325 " var local = 42;" | 7499 " var local = 42;" |
7326 " if (count < 1) { scheduleBreak(); loop(count + 1); }" | 7500 " if (count < 1) { scheduleBreak(); loop(count + 1); }" |
7327 "}" | 7501 "}" |
7328 "loop(0);"; | 7502 "loop(0);"; |
7329 v8::Script::Compile(v8::String::New(src))->Run(); | 7503 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), src))->Run(); |
7330 } | 7504 } |
7331 | 7505 |
7332 | 7506 |
7333 // Test that setting the terminate execution flag during debug break processing. | 7507 // Test that setting the terminate execution flag during debug break processing. |
7334 static void TestDebugBreakInLoop(const char* loop_head, | 7508 static void TestDebugBreakInLoop(const char* loop_head, |
7335 const char** loop_bodies, | 7509 const char** loop_bodies, |
7336 const char* loop_tail) { | 7510 const char* loop_tail) { |
7337 // Receive 100 breaks for each test and then terminate JavaScript execution. | 7511 // Receive 100 breaks for each test and then terminate JavaScript execution. |
7338 static const int kBreaksPerTest = 100; | 7512 static const int kBreaksPerTest = 100; |
7339 | 7513 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7463 " debug(b) \n" | 7637 " debug(b) \n" |
7464 "}; \n" | 7638 "}; \n" |
7465 "function g(b) { \n" | 7639 "function g(b) { \n" |
7466 " f(b); \n" | 7640 " f(b); \n" |
7467 "}; \n" | 7641 "}; \n" |
7468 "g(false); \n" | 7642 "g(false); \n" |
7469 "g(false); \n" | 7643 "g(false); \n" |
7470 "%OptimizeFunctionOnNextCall(g); \n" | 7644 "%OptimizeFunctionOnNextCall(g); \n" |
7471 "g(true);"; | 7645 "g(true);"; |
7472 v8::Debug::SetDebugEventListener2(DebugBreakInlineListener); | 7646 v8::Debug::SetDebugEventListener2(DebugBreakInlineListener); |
7473 inline_script = v8::Script::Compile(v8::String::New(source)); | 7647 inline_script = |
| 7648 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source)); |
7474 inline_script->Run(); | 7649 inline_script->Run(); |
7475 } | 7650 } |
7476 | 7651 |
7477 | 7652 |
7478 static void DebugEventStepNext( | 7653 static void DebugEventStepNext( |
7479 const v8::Debug::EventDetails& event_details) { | 7654 const v8::Debug::EventDetails& event_details) { |
7480 v8::DebugEvent event = event_details.GetEvent(); | 7655 v8::DebugEvent event = event_details.GetEvent(); |
7481 if (event == v8::Break) { | 7656 if (event == v8::Break) { |
7482 PrepareStep(StepNext); | 7657 PrepareStep(StepNext); |
7483 } | 7658 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7555 TEST(LiveEditDisabled) { | 7730 TEST(LiveEditDisabled) { |
7556 v8::internal::FLAG_allow_natives_syntax = true; | 7731 v8::internal::FLAG_allow_natives_syntax = true; |
7557 LocalContext env; | 7732 LocalContext env; |
7558 v8::HandleScope scope(env->GetIsolate()); | 7733 v8::HandleScope scope(env->GetIsolate()); |
7559 v8::Debug::SetLiveEditEnabled(false), env->GetIsolate(); | 7734 v8::Debug::SetLiveEditEnabled(false), env->GetIsolate(); |
7560 CompileRun("%LiveEditCompareStrings('', '')"); | 7735 CompileRun("%LiveEditCompareStrings('', '')"); |
7561 } | 7736 } |
7562 | 7737 |
7563 | 7738 |
7564 #endif // ENABLE_DEBUGGER_SUPPORT | 7739 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |