| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b744070 commit ab5bca3
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,10 +12,12 @@ static bool called_cb_1 = false; | |||
| 12 | 12 | static bool called_cb_2 = false; | |
| 13 | 13 | static bool called_cb_ordered_1 = false; | |
| 14 | 14 | static bool called_cb_ordered_2 = false; | |
| 15 | + static bool called_at_exit_js = false; | ||
| 15 | 16 | static void at_exit_callback1(void* arg); | |
| 16 | 17 | static void at_exit_callback2(void* arg); | |
| 17 | 18 | static void at_exit_callback_ordered1(void* arg); | |
| 18 | 19 | static void at_exit_callback_ordered2(void* arg); | |
| 20 | + static void at_exit_js(void* arg); | ||
| 19 | 21 | static std::string cb_1_arg; // NOLINT(runtime/string) | |
| 20 | 22 | ||
| 21 | 23 | class EnvironmentTest : public EnvironmentTestFixture { | |
@@ -91,6 +93,17 @@ TEST_F(EnvironmentTest, AtExitWithArgument) { | |||
| 91 | 93 | EXPECT_EQ(arg, cb_1_arg); | |
| 92 | 94 | } | |
| 93 | 95 | ||
| 96 | + TEST_F(EnvironmentTest, AtExitRunsJS) { | ||
| 97 | + const v8::HandleScope handle_scope(isolate_); | ||
| 98 | + const Argv argv; | ||
| 99 | + Env env {handle_scope, argv}; | ||
| 100 | + | ||
| 101 | + AtExit(*env, at_exit_js, static_cast<void*>(isolate_)); | ||
| 102 | + EXPECT_FALSE(called_at_exit_js); | ||
| 103 | + RunAtExit(*env); | ||
| 104 | + EXPECT_TRUE(called_at_exit_js); | ||
| 105 | + } | ||
| 106 | + | ||
| 94 | 107 | TEST_F(EnvironmentTest, MultipleEnvironmentsPerIsolate) { | |
| 95 | 108 | const v8::HandleScope handle_scope(isolate_); | |
| 96 | 109 | const Argv argv; | |
@@ -163,3 +176,12 @@ static void at_exit_callback_ordered2(void* arg) { | |||
| 163 | 176 | EXPECT_FALSE(called_cb_ordered_1); | |
| 164 | 177 | called_cb_ordered_2 = true; | |
| 165 | 178 | } | |
| 179 | + | ||
| 180 | + static void at_exit_js(void* arg) { | ||
| 181 | + v8::Isolate* isolate = static_cast<v8::Isolate*>(arg); | ||
| 182 | + v8::HandleScope handle_scope(isolate); | ||
| 183 | + v8::Local<v8::Object> obj = v8::Object::New(isolate); | ||
| 184 | + assert(!obj.IsEmpty()); // Assert VM is still alive. | ||
| 185 | + assert(obj->IsObject()); | ||
| 186 | + called_at_exit_js = true; | ||
| 187 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments