Perform GC on teardown of FXCG_UnitTest.
Otherwise, the heap is silently thrown away for these tests, and we
might miss issues involving tracing, etc.
-- use the actual isolate since it happens to be present.
Change-Id: I2faea565fe53f6a08934ef366501fc007a828fd8
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/73970
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/fxgc_unittest.cpp b/testing/fxgc_unittest.cpp
index 0e467cf..538565e 100644
--- a/testing/fxgc_unittest.cpp
+++ b/testing/fxgc_unittest.cpp
@@ -14,12 +14,18 @@
void FXGCUnitTest::SetUp() {
FXV8UnitTest::SetUp();
- FXGC_Initialize(V8TestEnvironment::GetInstance()->platform(), nullptr);
+ auto* env = V8TestEnvironment::GetInstance();
+ FXGC_Initialize(env->platform(), env->isolate());
heap_ = FXGC_CreateHeap();
ASSERT_TRUE(heap_);
}
void FXGCUnitTest::TearDown() {
+ FXGC_ForceGarbageCollection(heap_.get());
+ auto* env = V8TestEnvironment::GetInstance();
+ while (v8::platform::PumpMessageLoop(env->platform(), env->isolate()))
+ continue;
+
heap_.reset();
FXGC_Release();
FXV8UnitTest::TearDown();