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

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

Issue 2040853003: Add a convenience method to get the debugged context (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug/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
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 3b4f79a9ad05313e3e4de98525edc6981de46e60..3ed6ec8e2ece275bed4737f7cbaf0ef06f901f84 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -7180,6 +7180,40 @@ TEST(NoDebugContextWhenDebuggerDisabled) {
CHECK(context.IsEmpty());
}
+static void DebugEventCheckContext(
+ const v8::Debug::EventDetails& event_details) {
+ if (event_details.GetEvent() == v8::Break) {
+ v8::Isolate* isolate = event_details.GetIsolate();
+ CHECK(v8::Debug::GetDebuggedContext(isolate)
+ .ToLocalChecked()
+ ->Global()
+ ->Equals(isolate->GetCurrentContext(),
+ event_details.GetEventContext()->Global())
+ .FromJust());
+ }
+}
+
+static void CheckContext(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ CHECK(v8::Debug::GetDebuggedContext(args.GetIsolate()).IsEmpty());
+}
+
+TEST(DebuggedContext) {
+ DebugLocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+
+ v8::Debug::SetDebugEventListener(isolate, DebugEventCheckContext);
+
+ v8::Local<v8::Function> foo =
+ CompileFunction(&env, "function foo(){bar=0;}", "foo");
+
+ SetBreakPoint(foo, 0);
+ foo->Call(env.context(), env->Global(), 0, nullptr).ToLocalChecked();
+
+ v8::Local<v8::Function> fun = v8::FunctionTemplate::New(isolate, CheckContext)
+ ->GetFunction(env.context())
+ .ToLocalChecked();
+ fun->Call(env.context(), env->Global(), 0, nullptr).ToLocalChecked();
+}
static v8::Local<v8::Value> expected_callback_data;
static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
« no previous file with comments | « src/debug/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698