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

Unified Diff: test/unittests/api/exception-unittest.cc

Issue 2675203005: Clear pending message during Isolate::CancelScheduledExceptionFromTryCatch. (Closed)
Patch Set: Merge branch 'master' into schedule-clear-pending-message Created 3 years, 10 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/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/api/exception-unittest.cc
diff --git a/test/unittests/api/exception-unittest.cc b/test/unittests/api/exception-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b8f21cc4e294cc3099e64584e3d36aa4def1f77a
--- /dev/null
+++ b/test/unittests/api/exception-unittest.cc
@@ -0,0 +1,45 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "include/v8.h"
+#include "src/flags.h"
+#include "test/unittests/test-utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace {
+
+using APIExceptionTest = TestWithIsolate;
+
+class ScopedExposeGc {
+ public:
+ ScopedExposeGc() : was_exposed_(i::FLAG_expose_gc) {
+ i::FLAG_expose_gc = true;
+ }
+ ~ScopedExposeGc() { i::FLAG_expose_gc = was_exposed_; }
+
+ private:
+ const bool was_exposed_;
+};
+
+TEST_F(APIExceptionTest, ExceptionMessageDoesNotKeepContextAlive) {
+ ScopedExposeGc expose_gc;
+ Persistent<Context> weak_context;
+ {
+ HandleScope handle_scope(isolate());
+ Local<Context> context = Context::New(isolate());
+ weak_context.Reset(isolate(), context);
+ weak_context.SetWeak();
+
+ Context::Scope context_scope(context);
+ TryCatch try_catch(isolate());
+ isolate()->ThrowException(Undefined(isolate()));
+ }
+ isolate()->RequestGarbageCollectionForTesting(
+ Isolate::kFullGarbageCollection);
+ EXPECT_TRUE(weak_context.IsEmpty());
+}
+
+} // namespace
+} // namespace v8
« no previous file with comments | « test/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698