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

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

Issue 2962007: Debugger: introduce parametrized debug break. (Closed)
Patch Set: Comments addressed Created 10 years, 5 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
« src/debug.cc ('K') | « src/debug.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 6632 matching lines...) Expand 10 before | Expand all | Expand 10 after
6643 expected_context = v8::Context::New(); 6643 expected_context = v8::Context::New();
6644 v8::Context::Scope context_scope(expected_context); 6644 v8::Context::Scope context_scope(expected_context);
6645 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run(); 6645 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run();
6646 expected_context.Dispose(); 6646 expected_context.Dispose();
6647 expected_context.Clear(); 6647 expected_context.Clear();
6648 v8::Debug::SetDebugEventListener(NULL); 6648 v8::Debug::SetDebugEventListener(NULL);
6649 expected_context_data = v8::Handle<v8::Value>(); 6649 expected_context_data = v8::Handle<v8::Value>();
6650 CheckDebuggerUnloaded(); 6650 CheckDebuggerUnloaded();
6651 } 6651 }
6652 6652
6653
6654 static void* expected_break_data;
6655 static bool was_debug_break_called;
6656 static bool was_debug_event_called;
6657 static void DebugEventBreakDataChecker(const v8::Debug::EventDetails& details) {
6658 if (details.GetEvent() == v8::BreakForCommand) {
6659 CHECK_EQ(expected_break_data, details.GetClientData());
6660 was_debug_event_called = true;
6661 } else if (details.GetEvent() == v8::Break) {
6662 was_debug_break_called = true;
6663 }
6664 }
6665
6666 // Check that event details contain context where debug event occured.
6667 TEST(DebugEventBreakData) {
6668 v8::HandleScope scope;
6669 DebugLocalContext env;
6670 v8::Debug::SetDebugEventListener2(DebugEventBreakDataChecker);
6671
6672 TestClientData::constructor_call_counter = 0;
6673 TestClientData::destructor_call_counter = 0;
6674
6675 expected_break_data = NULL;
6676 was_debug_event_called = false;
6677 was_debug_break_called = false;
6678 v8::Debug::DebugBreakForCommand();
6679 v8::Script::Compile(v8::String::New("(function(x){return x;})(1);"))->Run();
6680 CHECK(was_debug_event_called);
6681 CHECK(!was_debug_break_called);
6682
6683 TestClientData* data1 = new TestClientData();
6684 expected_break_data = data1;
6685 was_debug_event_called = false;
6686 was_debug_break_called = false;
6687 v8::Debug::DebugBreakForCommand(data1);
6688 v8::Script::Compile(v8::String::New("(function(x){return x+1;})(1);"))->Run();
6689 CHECK(was_debug_event_called);
6690 CHECK(!was_debug_break_called);
6691
6692 expected_break_data = NULL;
6693 was_debug_event_called = false;
6694 was_debug_break_called = false;
6695 v8::Debug::DebugBreak();
6696 v8::Script::Compile(v8::String::New("(function(x){return x+2;})(1);"))->Run();
6697 CHECK(!was_debug_event_called);
6698 CHECK(was_debug_break_called);
6699
6700 TestClientData* data2 = new TestClientData();
6701 expected_break_data = data2;
6702 was_debug_event_called = false;
6703 was_debug_break_called = false;
6704 v8::Debug::DebugBreak();
6705 v8::Debug::DebugBreakForCommand(data2);
6706 v8::Script::Compile(v8::String::New("(function(x){return x+3;})(1);"))->Run();
6707 CHECK(was_debug_event_called);
6708 CHECK(was_debug_break_called);
6709
6710 CHECK_EQ(2, TestClientData::constructor_call_counter);
6711 CHECK_EQ(TestClientData::constructor_call_counter,
6712 TestClientData::destructor_call_counter);
6713
6714 v8::Debug::SetDebugEventListener(NULL);
6715 CheckDebuggerUnloaded();
6716 }
6717
6653 #endif // ENABLE_DEBUGGER_SUPPORT 6718 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« src/debug.cc ('K') | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698