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

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. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« 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..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;
« no previous file with comments | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698