OLD | NEW |
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 6178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6189 debugger_context = v8::Handle<v8::Context>(); | 6189 debugger_context = v8::Handle<v8::Context>(); |
6190 CheckDebuggerUnloaded(); | 6190 CheckDebuggerUnloaded(); |
6191 } | 6191 } |
6192 | 6192 |
6193 | 6193 |
6194 TEST(DebugContextIsPreservedBetweenAccesses) { | 6194 TEST(DebugContextIsPreservedBetweenAccesses) { |
6195 v8::HandleScope scope; | 6195 v8::HandleScope scope; |
6196 v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext(); | 6196 v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext(); |
6197 v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext(); | 6197 v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext(); |
6198 CHECK_EQ(*context1, *context2); | 6198 CHECK_EQ(*context1, *context2); |
6199 // Make sure debugger is unloaded before running other tests. | 6199 } |
6200 v8::internal::ForceUnloadDebugger(); | 6200 |
| 6201 |
| 6202 static v8::Handle<v8::Value> expected_callback_data; |
| 6203 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { |
| 6204 CHECK(details.GetEventContext() == expected_context); |
| 6205 CHECK_EQ(expected_callback_data, details.GetCallbackData()); |
| 6206 } |
| 6207 |
| 6208 // Check that event details contain context where debug event occured. |
| 6209 TEST(DebugEventContext) { |
| 6210 v8::HandleScope scope; |
| 6211 expected_callback_data = v8::Int32::New(2010); |
| 6212 v8::Debug::SetDebugEventListener2(DebugEventContextChecker, |
| 6213 expected_callback_data); |
| 6214 expected_context = v8::Context::New(); |
| 6215 v8::Context::Scope context_scope(expected_context); |
| 6216 v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run(); |
| 6217 expected_context.Dispose(); |
| 6218 expected_context.Clear(); |
| 6219 v8::Debug::SetDebugEventListener(NULL); |
| 6220 expected_context_data = v8::Handle<v8::Value>(); |
6201 CheckDebuggerUnloaded(); | 6221 CheckDebuggerUnloaded(); |
6202 } | 6222 } |
| 6223 |
OLD | NEW |