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

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: Created 6 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
« src/debug.cc ('K') | « 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..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;
« src/debug.cc ('K') | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698