Add (disabled) tests for desired cppgc behavior.

These illustrate a couple of lifetime behaviours that we'd like to
see from CPPGC, but haven't been implemented yet. We'll probably
need both of these to pass before we can use CPPGC on some more
complex structures.

Change-Id: I937ad90f03923ce5c82641dcfd9a8ff9502135e4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/71075
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/gc/heap_embeddertest.cpp b/fxjs/gc/heap_embeddertest.cpp
index b17a4ae..90b45d2 100644
--- a/fxjs/gc/heap_embeddertest.cpp
+++ b/fxjs/gc/heap_embeddertest.cpp
@@ -106,3 +106,43 @@
   EXPECT_EQ(0u, PseudoCollectible::DeadCount());
   PseudoCollectible::Clear();
 }
+
+// TODO(tsepez): enable when CPPGC fixes this segv.
+TEST_F(HeapEmbedderTest, DISABLED_DeleteHeapHasReferences) {
+  FXGCScopedHeap heap1 = FXGC_CreateHeap();
+  ASSERT_TRUE(heap1);
+
+  PseudoCollectible::s_persistent_ =
+      cppgc::MakeGarbageCollected<PseudoCollectible>(
+          heap1->GetAllocationHandle());
+  EXPECT_TRUE(PseudoCollectible::s_persistent_->IsLive());
+  EXPECT_EQ(1u, PseudoCollectible::LiveCount());
+  EXPECT_EQ(0u, PseudoCollectible::DeadCount());
+
+  heap1.reset();
+  PumpPlatformMessageLoop();
+  EXPECT_FALSE(PseudoCollectible::s_persistent_);
+  EXPECT_EQ(1u, PseudoCollectible::LiveCount());
+  EXPECT_EQ(1u, PseudoCollectible::DeadCount());
+  PseudoCollectible::Clear();
+}
+
+// TODO(tsepez): enable when CPPGC cleans this up.
+TEST_F(HeapEmbedderTest, DISABLED_DeleteHeapNoReferences) {
+  FXGCScopedHeap heap1 = FXGC_CreateHeap();
+  ASSERT_TRUE(heap1);
+
+  PseudoCollectible::s_persistent_ =
+      cppgc::MakeGarbageCollected<PseudoCollectible>(
+          heap1->GetAllocationHandle());
+  EXPECT_TRUE(PseudoCollectible::s_persistent_->IsLive());
+  EXPECT_EQ(1u, PseudoCollectible::LiveCount());
+  EXPECT_EQ(0u, PseudoCollectible::DeadCount());
+
+  PseudoCollectible::s_persistent_ = nullptr;
+  heap1.reset();
+  PumpPlatformMessageLoop();
+  EXPECT_EQ(1u, PseudoCollectible::LiveCount());
+  EXPECT_EQ(1u, PseudoCollectible::DeadCount());
+  PseudoCollectible::Clear();
+}