Index: test/cctest/test-debug.cc |
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc |
index c3c65fd2f0256113f9594b29681ce2e136e0a76a..66e83daf2bfb7ad5152e0d1de9738a7ee6d1f8e1 100644 |
--- a/test/cctest/test-debug.cc |
+++ b/test/cctest/test-debug.cc |
@@ -7396,6 +7396,47 @@ 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 { |
Sven Panne
2014/12/18 14:53:31
Use OVERRIDE, not all our toolchains support overr
alph
2014/12/18 15:05:01
Done.
|
+ 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 { |
Sven Panne
2014/12/18 14:53:31
Same here.
alph
2014/12/18 15:05:01
Done.
|
+ 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); |
+ // Delaying the task increases probability the task is injected while the |
+ // loop is already running. |
Sven Panne
2014/12/18 14:53:31
Remove the comment, there's no delay anymore.
alph
2014/12/18 15:05:01
Done.
|
+ AsyncTask async_task(env->GetIsolate(), task); |
+ CompileRun("var stop = false;"); |
+ async_task.Start(); |
+ CompileRun("while (!stop) {}"); |
Sven Panne
2014/12/18 14:53:31
Well, without any kind of handshake (via a native
alph
2014/12/18 15:05:01
Technically the test doesn't care what was the VM
|
+} |
+ |
+ |
TEST(LiveEditEnabled) { |
v8::internal::FLAG_allow_natives_syntax = true; |
LocalContext env; |