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

Unified Diff: test/cctest/test-debug.cc

Issue 113698: Return empty handle from GetEventContext for ScriptCollected events (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
===================================================================
--- test/cctest/test-debug.cc (revision 2022)
+++ test/cctest/test-debug.cc (working copy)
@@ -4817,7 +4817,7 @@
v8::HandleScope scope;
DebugLocalContext env;
- // Request the loaded scripte to initialize the debugger script cache.
+ // Request the loaded scripts to initialize the debugger script cache.
Debug::GetLoadedScripts();
// Do garbage collection to ensure that only the script in this test will be
@@ -4841,3 +4841,49 @@
v8::Debug::SetDebugEventListener(NULL);
CheckDebuggerUnloaded();
}
+
+
+// Debug event listener which counts the script collected events.
+int script_collected_message_count = 0;
+static void ScriptCollectedMessageHandler(const v8::Debug::Message& message) {
+ // Count the number of scripts collected.
+ if (message.IsEvent() && message.GetEvent() == v8::ScriptCollected) {
+ script_collected_message_count++;
+ v8::Handle<v8::Context> context = message.GetEventContext();
+ CHECK(context.IsEmpty());
+ }
+}
+
+
+// Test that GetEventContext doesn't fail and return empty handle for
+// ScriptCollected events.
+TEST(ScriptCollectedEventContext) {
+ break_point_hit_count = 0;
+ v8::HandleScope scope;
+
+ { // Scope for the DebugLocalContext.
+ DebugLocalContext env;
+
+ // Request the loaded scripts to initialize the debugger script cache.
+ Debug::GetLoadedScripts();
+
+ // Do garbage collection to ensure that only the script in this test will be
+ // collected afterwards.
+ Heap::CollectAllGarbage();
+
+ script_collected_count = 0;
+ v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler);
+ {
+ v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
+ v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
+ }
+ }
+
+ // Do garbage collection to collect the script above which is no longer
+ // referenced.
+ Heap::CollectAllGarbage();
+
+ CHECK_EQ(2, script_collected_message_count);
+
+ v8::Debug::SetMessageHandler2(NULL);
+}
« no previous file with comments | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698