Skip to content

Commit abfc8ae

Browse files
committed
test: drain platform before unregistering isolate
PR-URL: #27375 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent f73d5c2 commit abfc8ae

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

test/cctest/node_test_fixture.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class NodeTestFixture : public ::testing::Test {
107107
void TearDown() override {
108108
isolate_->Exit();
109109
isolate_->Dispose();
110+
platform->DrainTasks(isolate_);
110111
platform->UnregisterIsolate(isolate_);
111112
isolate_ = nullptr;
112113
}

test/cctest/test_environment.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ TEST_F(EnvironmentTest, MultipleEnvironmentsPerIsolate) {
8888
EXPECT_TRUE(called_cb_2);
8989
}
9090

91+
TEST_F(EnvironmentTest, NoEnvironmentSanity) {
92+
const v8::HandleScope handle_scope(isolate_);
93+
v8::Local<v8::Context> context = v8::Context::New(isolate_);
94+
EXPECT_EQ(node::Environment::GetCurrent(context), nullptr);
95+
EXPECT_EQ(node::GetCurrentEnvironment(context), nullptr);
96+
EXPECT_EQ(node::Environment::GetCurrent(isolate_), nullptr);
97+
98+
v8::Context::Scope context_scope(context);
99+
EXPECT_EQ(node::Environment::GetCurrent(context), nullptr);
100+
EXPECT_EQ(node::GetCurrentEnvironment(context), nullptr);
101+
EXPECT_EQ(node::Environment::GetCurrent(isolate_), nullptr);
102+
}
103+
91104
TEST_F(EnvironmentTest, NonNodeJSContext) {
92105
const v8::HandleScope handle_scope(isolate_);
93106
const Argv argv;

0 commit comments

Comments
 (0)