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 5645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5656 foo->Call(debugee_context, env->Global(), 0, NULL).ToLocalChecked(); | 5656 foo->Call(debugee_context, env->Global(), 0, NULL).ToLocalChecked(); |
5657 CHECK_EQ(1, break_point_hit_count); | 5657 CHECK_EQ(1, break_point_hit_count); |
5658 | 5658 |
5659 v8::Debug::SetDebugEventListener(isolate, nullptr); | 5659 v8::Debug::SetDebugEventListener(isolate, nullptr); |
5660 debugee_context = v8::Local<v8::Context>(); | 5660 debugee_context = v8::Local<v8::Context>(); |
5661 debugger_context = v8::Local<v8::Context>(); | 5661 debugger_context = v8::Local<v8::Context>(); |
5662 CheckDebuggerUnloaded(isolate); | 5662 CheckDebuggerUnloaded(isolate); |
5663 } | 5663 } |
5664 | 5664 |
5665 | 5665 |
| 5666 TEST(DebugContextIsPreservedBetweenAccesses) { |
| 5667 v8::HandleScope scope(CcTest::isolate()); |
| 5668 v8::Debug::SetDebugEventListener(CcTest::isolate(), |
| 5669 DebugEventBreakPointHitCount); |
| 5670 v8::Local<v8::Context> context1 = |
| 5671 v8::Debug::GetDebugContext(CcTest::isolate()); |
| 5672 v8::Local<v8::Context> context2 = |
| 5673 v8::Debug::GetDebugContext(CcTest::isolate()); |
| 5674 CHECK(v8::Utils::OpenHandle(*context1).is_identical_to( |
| 5675 v8::Utils::OpenHandle(*context2))); |
| 5676 v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr); |
| 5677 } |
| 5678 |
| 5679 |
| 5680 TEST(NoDebugContextWhenDebuggerDisabled) { |
| 5681 v8::HandleScope scope(CcTest::isolate()); |
| 5682 v8::Local<v8::Context> context = |
| 5683 v8::Debug::GetDebugContext(CcTest::isolate()); |
| 5684 CHECK(context.IsEmpty()); |
| 5685 } |
| 5686 |
5666 static v8::Local<v8::Value> expected_callback_data; | 5687 static v8::Local<v8::Value> expected_callback_data; |
5667 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { | 5688 static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { |
5668 CHECK(details.GetEventContext() == expected_context); | 5689 CHECK(details.GetEventContext() == expected_context); |
5669 CHECK(expected_callback_data->Equals(details.GetEventContext(), | 5690 CHECK(expected_callback_data->Equals(details.GetEventContext(), |
5670 details.GetCallbackData()) | 5691 details.GetCallbackData()) |
5671 .FromJust()); | 5692 .FromJust()); |
5672 } | 5693 } |
5673 | 5694 |
5674 | 5695 |
5675 // Check that event details contain context where debug event occured. | 5696 // Check that event details contain context where debug event occured. |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6637 "function foo() {\n" | 6658 "function foo() {\n" |
6638 " try { throw new Error(); } catch (e) {}\n" | 6659 " try { throw new Error(); } catch (e) {}\n" |
6639 "}\n" | 6660 "}\n" |
6640 "debugger;\n" | 6661 "debugger;\n" |
6641 "foo();\n" | 6662 "foo();\n" |
6642 "foo();\n"); | 6663 "foo();\n"); |
6643 | 6664 |
6644 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 6665 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
6645 CHECK_EQ(break_point_hit_count, 4); | 6666 CHECK_EQ(break_point_hit_count, 4); |
6646 } | 6667 } |
OLD | NEW |