Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: test/cctest/test-debug.cc

Issue 264333007: Add OnCompileError handler and v8::CompileError debug event (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parser.cc ('k') | test/mjsunit/debug-compile-event.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6354 matching lines...) Expand 10 before | Expand all | Expand 10 after
6365 6365
6366 // Setting listener to NULL should cause debugger unload. 6366 // Setting listener to NULL should cause debugger unload.
6367 v8::Debug::SetMessageHandler(NULL); 6367 v8::Debug::SetMessageHandler(NULL);
6368 CheckDebuggerUnloaded(); 6368 CheckDebuggerUnloaded();
6369 6369
6370 // Compilation cache should be disabled when debugger is active. 6370 // Compilation cache should be disabled when debugger is active.
6371 CHECK_EQ(2, after_compile_message_count); 6371 CHECK_EQ(2, after_compile_message_count);
6372 } 6372 }
6373 6373
6374 6374
6375 // Syntax error event handler which counts a number of events.
6376 int compile_error_event_count = 0;
6377
6378 static void CompileErrorEventCounterClear() {
6379 compile_error_event_count = 0;
6380 }
6381
6382 static void CompileErrorEventCounter(
6383 const v8::Debug::EventDetails& event_details) {
6384 v8::DebugEvent event = event_details.GetEvent();
6385
6386 if (event == v8::CompileError) {
6387 compile_error_event_count++;
6388 }
6389 }
6390
6391
6392 // Tests that syntax error event is sent as many times as there are scripts
6393 // with syntax error compiled.
6394 TEST(SyntaxErrorMessageOnSyntaxException) {
6395 DebugLocalContext env;
6396 v8::HandleScope scope(env->GetIsolate());
6397
6398 // For this test, we want to break on uncaught exceptions:
6399 ChangeBreakOnException(false, true);
6400
6401 v8::Debug::SetDebugEventListener(CompileErrorEventCounter);
6402
6403 CompileErrorEventCounterClear();
6404
6405 // Check initial state.
6406 CHECK_EQ(0, compile_error_event_count);
6407
6408 // Throws SyntaxError: Unexpected end of input
6409 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "+++"));
6410 CHECK_EQ(1, compile_error_event_count);
6411
6412 v8::Script::Compile(
6413 v8::String::NewFromUtf8(env->GetIsolate(), "/sel\\/: \\"));
6414 CHECK_EQ(2, compile_error_event_count);
6415
6416 v8::Script::Compile(
6417 v8::String::NewFromUtf8(env->GetIsolate(), "JSON.parse('1234:')"));
6418 CHECK_EQ(2, compile_error_event_count);
6419
6420 v8::Script::Compile(
6421 v8::String::NewFromUtf8(env->GetIsolate(), "new RegExp('/\\/\\\\');"));
6422 CHECK_EQ(2, compile_error_event_count);
6423
6424 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "throw 1;"));
6425 CHECK_EQ(2, compile_error_event_count);
6426 }
6427
6428
6375 // Tests that break event is sent when message handler is reset. 6429 // Tests that break event is sent when message handler is reset.
6376 TEST(BreakMessageWhenMessageHandlerIsReset) { 6430 TEST(BreakMessageWhenMessageHandlerIsReset) {
6377 DebugLocalContext env; 6431 DebugLocalContext env;
6378 v8::HandleScope scope(env->GetIsolate()); 6432 v8::HandleScope scope(env->GetIsolate());
6379 after_compile_message_count = 0; 6433 after_compile_message_count = 0;
6380 const char* script = "function f() {};"; 6434 const char* script = "function f() {};";
6381 6435
6382 v8::Debug::SetMessageHandler(AfterCompileMessageHandler); 6436 v8::Debug::SetMessageHandler(AfterCompileMessageHandler);
6383 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script)) 6437 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), script))
6384 ->Run(); 6438 ->Run();
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
7464 TEST(DebugBreakOffThreadTerminate) { 7518 TEST(DebugBreakOffThreadTerminate) {
7465 DebugLocalContext env; 7519 DebugLocalContext env;
7466 v8::Isolate* isolate = env->GetIsolate(); 7520 v8::Isolate* isolate = env->GetIsolate();
7467 v8::HandleScope scope(isolate); 7521 v8::HandleScope scope(isolate);
7468 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate); 7522 v8::Debug::SetDebugEventListener(DebugBreakTriggerTerminate);
7469 TerminationThread terminator(isolate); 7523 TerminationThread terminator(isolate);
7470 terminator.Start(); 7524 terminator.Start();
7471 v8::Debug::DebugBreak(isolate); 7525 v8::Debug::DebugBreak(isolate);
7472 CompileRun("while (true);"); 7526 CompileRun("while (true);");
7473 } 7527 }
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | test/mjsunit/debug-compile-event.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698