Chromium Code Reviews| Index: test/cctest/test-debug.cc |
| diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc |
| index c3c65fd2f0256113f9594b29681ce2e136e0a76a..54d031206f6be73f9715b1024d0b046fdbc8dc5d 100644 |
| --- a/test/cctest/test-debug.cc |
| +++ b/test/cctest/test-debug.cc |
| @@ -7396,6 +7396,50 @@ TEST(DebuggerCreatesContextIffActive) { |
| } |
| +class DelayedTask : public v8::base::Thread { |
| + public: |
| + DelayedTask(v8::Isolate* isolate, v8::Debug::Task* task, int delay_ms) |
| + : Thread(Options("DelayedTask")), |
| + isolate_(isolate), |
| + task_(task), |
| + delay_ms_(delay_ms) {} |
| + void Run() override { |
| + v8::base::OS::Sleep(delay_ms_); |
| + v8::Debug::BreakAndRun(isolate_, task_); |
| + task_ = NULL; |
| + } |
| + |
| + private: |
| + v8::Isolate* isolate_; |
| + v8::Debug::Task* task_; |
| + int delay_ms_; |
| +}; |
| + |
| + |
| +class StopExecutionTask : public v8::Debug::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::Debug::Task* task = new StopExecutionTask(env); |
| + DelayedTask delayed_task(env->GetIsolate(), task, 10); |
|
yurys
2014/12/17 15:29:09
Please add a comment on why we need the delay.
|
| + CompileRun("var stop = false;"); |
| + delayed_task.Start(); |
| + CompileRun("while (!stop) {}"); |
| +} |
| + |
| + |
| TEST(LiveEditEnabled) { |
| v8::internal::FLAG_allow_natives_syntax = true; |
| LocalContext env; |