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

Unified Diff: test/inspector/inspector-test.cc

Issue 2574803002: [inspector] add async instrumentation for setTimeout in tests (Closed)
Patch Set: Created 4 years 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
Index: test/inspector/inspector-test.cc
diff --git a/test/inspector/inspector-test.cc b/test/inspector/inspector-test.cc
index 401aca077650afa8413274ba82d6920addc57d29..1b1a1fd7de22195a365b27151e41ec3eacf0e686 100644
--- a/test/inspector/inspector-test.cc
+++ b/test/inspector/inspector-test.cc
@@ -177,7 +177,7 @@ class UtilsExtension : public v8::Extension {
backend_runner_->Append(new ExecuteStringTask(
ToVector(args[0].As<v8::String>()), args[1].As<v8::String>(),
- args[2].As<v8::Int32>(), args[3].As<v8::Int32>()));
+ args[2].As<v8::Int32>(), args[3].As<v8::Int32>(), false));
}
};
@@ -203,9 +203,15 @@ class SetTimeoutTask : public TaskRunner::Task {
v8::MaybeLocal<v8::Value> result;
v8_inspector::V8Inspector* inspector =
InspectorClientImpl::InspectorFromContext(context);
- if (inspector) inspector->willExecuteScript(context, function->ScriptId());
+ if (inspector) {
+ inspector->willExecuteScript(context, function->ScriptId());
+ inspector->asyncTaskStarted(this);
+ }
result = function->Call(context, context->Global(), 0, nullptr);
- if (inspector) inspector->didExecuteScript(context);
+ if (inspector) {
+ inspector->asyncTaskFinished(this);
+ inspector->didExecuteScript(context);
+ }
}
private:
@@ -234,14 +240,26 @@ class SetTimeoutExtension : public v8::Extension {
}
v8::Isolate* isolate = args.GetIsolate();
v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ std::unique_ptr<TaskRunner::Task> task;
if (args[0]->IsFunction()) {
- TaskRunner::FromContext(context)->Append(
+ task.reset(
new SetTimeoutTask(isolate, v8::Local<v8::Function>::Cast(args[0])));
} else {
- TaskRunner::FromContext(context)->Append(new ExecuteStringTask(
+ task.reset(new ExecuteStringTask(
ToVector(args[0].As<v8::String>()), v8::String::Empty(isolate),
- v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0)));
+ v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), true));
+ }
+ const char* set_timeout = "setTimeout";
+ v8_inspector::V8Inspector* inspector =
+ InspectorClientImpl::InspectorFromContext(context);
+ if (inspector) {
+ inspector->asyncTaskScheduled(
dgozman 2016/12/13 17:31:54 Why doesn't ExecuteStringTask do this in construct
kozy 2016/12/13 18:24:26 Done.
+ v8_inspector::StringView(
+ reinterpret_cast<const uint8_t*>(set_timeout),
+ strlen(set_timeout)),
+ task.get(), false);
}
+ TaskRunner::FromContext(context)->Append(task.release());
}
};
@@ -336,7 +354,7 @@ class FrontendChannelImpl : public InspectorClientImpl::FrontendChannel {
frontend_task_runner_->Append(new ExecuteStringTask(
ToVector(result), v8::String::Empty(isolate),
- v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0)));
+ v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), false));
}
private:

Powered by Google App Engine
This is Rietveld 408576698