Chromium Code Reviews

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

Issue 812583003: Support tasks injection into a running VM. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressing comments. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« 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
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index c3c65fd2f0256113f9594b29681ce2e136e0a76a..e8120f897a9c7f9e0f1c2ab0661f4bc46dbad9e3 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -7396,6 +7396,45 @@ TEST(DebuggerCreatesContextIffActive) {
}
+class AsyncTask : public v8::base::Thread {
+ public:
+ AsyncTask(v8::Isolate* isolate, v8::Task* task)
+ : Thread(Options("AsyncTask")), isolate_(isolate), task_(task) {}
+ void Run() OVERRIDE {
+ v8::Debug::BreakAndRun(isolate_, task_);
+ task_ = NULL;
+ }
+
+ private:
+ v8::Isolate* isolate_;
+ v8::Task* task_;
+};
+
+
+class StopExecutionTask : public v8::Task {
+ public:
+ explicit StopExecutionTask(LocalContext& context) : context_(context) {}
+ void Run() OVERRIDE {
+ context_->Global()->Set(v8_str("stop"), v8::True(context_->GetIsolate()));
+ }
+
+ private:
+ LocalContext& context_;
+};
+
+
+TEST(RunTaskWhileLooping) {
+ LocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
+
+ v8::Task* task = new StopExecutionTask(env);
+ AsyncTask async_task(env->GetIsolate(), task);
+ CompileRun("var stop = false;");
+ async_task.Start();
+ CompileRun("while (!stop) {}");
+}
+
+
TEST(LiveEditEnabled) {
v8::internal::FLAG_allow_natives_syntax = true;
LocalContext env;
« no previous file with comments | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine