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

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: Added a comment. 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.h ('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..84d45ff4de2963eede546cf5446fa4c476b0f9fe 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -7396,6 +7396,52 @@ 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);
+ // Delaying the task increases probability the task is injected while the
Benedikt Meurer 2014/12/18 04:11:57 This is rather fragile. Can we have a more robust
Sven Panne 2014/12/18 08:27:51 I would even go a step further: Without proper syn
alph 2014/12/18 14:28:03 This test case it robust. It does not fail/flake d
alph 2014/12/18 14:28:03 Again, this Sleep does not lead to flakiness. Ther
+ // loop is already running.
+ DelayedTask delayed_task(env->GetIsolate(), task, 10);
+ CompileRun("var stop = false;");
+ delayed_task.Start();
+ CompileRun("while (!stop) {}");
+}
+
+
TEST(LiveEditEnabled) {
v8::internal::FLAG_allow_natives_syntax = true;
LocalContext env;
« src/debug.h ('K') | « src/debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698