Index: test/cctest/test-debug.cc |
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc |
index c3c65fd2f0256113f9594b29681ce2e136e0a76a..fa2a24b10370a9ed187862173cf5bbe8520a8016 100644 |
--- a/test/cctest/test-debug.cc |
+++ b/test/cctest/test-debug.cc |
@@ -7396,6 +7396,49 @@ 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_); |
yurys
2014/12/17 14:25:03
We can avoid this Sleep. E.g. "while" loop below c
alph
2014/12/17 15:05:46
I would like to make sure the BreakAndRun is engag
|
+ v8::Debug::BreakAndRun(isolate_, task_); |
yurys
2014/12/17 14:25:03
task_ = NULL?
alph
2014/12/17 15:05:46
Done.
|
+ } |
+ |
+ 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())); |
yurys
2014/12/17 14:25:03
We can use a static C++ variable instead, it would
alph
2014/12/17 15:05:46
See my comment above. I'd like it to be a pure JS
|
+ } |
+ |
+ 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, 100); |
yurys
2014/12/17 14:25:03
Or can we at least reduce the delay to 10 or somet
alph
2014/12/17 15:05:46
Acknowledged.
|
+ CompileRun("var stop = false;"); |
+ delayed_task.Start(); |
+ CompileRun("while (!stop) {}"); |
+} |
+ |
+ |
TEST(LiveEditEnabled) { |
v8::internal::FLAG_allow_natives_syntax = true; |
LocalContext env; |