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

Unified Diff: test/cctest/test-thread-termination.cc

Issue 294943009: Allow microtasks to throw exceptions and handle them gracefully (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use existing Suppression scope Created 6 years, 7 months 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 | « test/cctest/test-api.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-thread-termination.cc
diff --git a/test/cctest/test-thread-termination.cc b/test/cctest/test-thread-termination.cc
index 569ee95c644824fd229da2c31789cbe24bbde923..e949569be3eb0115eca156d38ca6c2e13ef74803 100644
--- a/test/cctest/test-thread-termination.cc
+++ b/test/cctest/test-thread-termination.cc
@@ -358,3 +358,47 @@ TEST(TerminateCancelTerminateFromThreadItself) {
// Check that execution completed with correct return value.
CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed")));
}
+
+
+void MicrotaskShouldNotRun(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ CHECK(false);
+}
+
+
+void MicrotaskLoopForever(const v8::FunctionCallbackInfo<v8::Value>& info) {
+ v8::Isolate* isolate = info.GetIsolate();
+ v8::HandleScope scope(isolate);
+ // Enqueue another should-not-run task to ensure we clean out the queue
+ // when we terminate.
+ isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskShouldNotRun));
+ CompileRun("terminate(); while (true) { }");
+ CHECK(v8::V8::IsExecutionTerminating());
+}
+
+
+TEST(TerminateFromOtherThreadWhileMicrotaskRunning) {
+ semaphore = new v8::internal::Semaphore(0);
+ TerminatorThread thread(CcTest::i_isolate());
+ thread.Start();
+
+ v8::Isolate* isolate = CcTest::isolate();
+ isolate->SetAutorunMicrotasks(false);
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::ObjectTemplate> global =
+ CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop);
+ v8::Handle<v8::Context> context =
+ v8::Context::New(CcTest::isolate(), NULL, global);
+ v8::Context::Scope context_scope(context);
+ isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskLoopForever));
+ // The second task should never be run because we bail out if we're
+ // terminating.
+ isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskShouldNotRun));
+ isolate->RunMicrotasks();
+
+ v8::V8::CancelTerminateExecution(isolate);
+ isolate->RunMicrotasks(); // should not run MicrotaskShouldNotRun
+
+ thread.Join();
+ delete semaphore;
+ semaphore = NULL;
+}
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698