| 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 6358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6369 | 6369 |
| 6370 // Setting listener to NULL should cause debugger unload. | 6370 // Setting listener to NULL should cause debugger unload. |
| 6371 v8::Debug::SetMessageHandler(NULL); | 6371 v8::Debug::SetMessageHandler(NULL); |
| 6372 CheckDebuggerUnloaded(); | 6372 CheckDebuggerUnloaded(); |
| 6373 | 6373 |
| 6374 // Compilation cache should be disabled when debugger is active. | 6374 // Compilation cache should be disabled when debugger is active. |
| 6375 CHECK_EQ(2, after_compile_message_count); | 6375 CHECK_EQ(2, after_compile_message_count); |
| 6376 } | 6376 } |
| 6377 | 6377 |
| 6378 | 6378 |
| 6379 // Syntax error event handler which counts a number of events. | |
| 6380 int compile_error_event_count = 0; | |
| 6381 | |
| 6382 static void CompileErrorEventCounterClear() { | |
| 6383 compile_error_event_count = 0; | |
| 6384 } | |
| 6385 | |
| 6386 static void CompileErrorEventCounter( | |
| 6387 const v8::Debug::EventDetails& event_details) { | |
| 6388 v8::DebugEvent event = event_details.GetEvent(); | |
| 6389 | |
| 6390 if (event == v8::CompileError) { | |
| 6391 compile_error_event_count++; | |
| 6392 } | |
| 6393 } | |
| 6394 | |
| 6395 | |
| 6396 // Tests that syntax error event is sent as many times as there are scripts | |
| 6397 // with syntax error compiled. | |
| 6398 TEST(SyntaxErrorMessageOnSyntaxException) { | |
| 6399 DebugLocalContext env; | |
| 6400 v8::HandleScope scope(env->GetIsolate()); | |
| 6401 | |
| 6402 // For this test, we want to break on uncaught exceptions: | |
| 6403 ChangeBreakOnException(false, true); | |
| 6404 | |
| 6405 v8::Debug::SetDebugEventListener(CompileErrorEventCounter); | |
| 6406 | |
| 6407 CompileErrorEventCounterClear(); | |
| 6408 | |
| 6409 // Check initial state. | |
| 6410 CHECK_EQ(0, compile_error_event_count); | |
| 6411 | |
| 6412 // Throws SyntaxError: Unexpected end of input | |
| 6413 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "+++")); | |
| 6414 CHECK_EQ(1, compile_error_event_count); | |
| 6415 | |
| 6416 v8::Script::Compile( | |
| 6417 v8::String::NewFromUtf8(env->GetIsolate(), "/sel\\/: \\")); | |
| 6418 CHECK_EQ(2, compile_error_event_count); | |
| 6419 | |
| 6420 v8::Script::Compile( | |
| 6421 v8::String::NewFromUtf8(env->GetIsolate(), "JSON.parse('1234:')")); | |
| 6422 CHECK_EQ(2, compile_error_event_count); | |
| 6423 | |
| 6424 v8::Script::Compile( | |
| 6425 v8::String::NewFromUtf8(env->GetIsolate(), "new RegExp('/\\/\\\\');")); | |
| 6426 CHECK_EQ(2, compile_error_event_count); | |
| 6427 | |
| 6428 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "throw 1;")); | |
| 6429 CHECK_EQ(2, compile_error_event_count); | |
| 6430 } | |
| 6431 | |
| 6432 | |
| 6433 // Tests that break event is sent when message handler is reset. | 6379 // Tests that break event is sent when message handler is reset. |
| 6434 TEST(BreakMessageWhenMessageHandlerIsReset) { | 6380 TEST(BreakMessageWhenMessageHandlerIsReset) { |
| 6435 DebugLocalContext env; | 6381 DebugLocalContext env; |
| 6436 v8::HandleScope scope(env->GetIsolate()); | 6382 v8::HandleScope scope(env->GetIsolate()); |
| 6437 after_compile_message_count = 0; | 6383 after_compile_message_count = 0; |
| 6438 const char* script = "function f() {};"; | 6384 const char* script = "function f() {};"; |
| 6439 | 6385 |
| 6440 v8::Debug::SetMessageHandler(AfterCompileMessageHandler); | 6386 v8::Debug::SetMessageHandler(AfterCompileMessageHandler); |
| 6441 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script)) | 6387 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script)) |
| 6442 ->Run(); | 6388 ->Run(); |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7522 TEST(DebugBreakOffThreadTerminate) { | 7468 TEST(DebugBreakOffThreadTerminate) { |
| 7523 DebugLocalContext env; | 7469 DebugLocalContext env; |
| 7524 v8::Isolate* isolate = env->GetIsolate(); | 7470 v8::Isolate* isolate = env->GetIsolate(); |
| 7525 v8::HandleScope scope(isolate); | 7471 v8::HandleScope scope(isolate); |
| 7526 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate); | 7472 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate); |
| 7527 TerminationThread terminator(isolate); | 7473 TerminationThread terminator(isolate); |
| 7528 terminator.Start(); | 7474 terminator.Start(); |
| 7529 v8::Debug::DebugBreak(isolate); | 7475 v8::Debug::DebugBreak(isolate); |
| 7530 CompileRun("while (true);"); | 7476 CompileRun("while (true);"); |
| 7531 } | 7477 } |
| OLD | NEW |