Index: third_party/WebKit/Source/platform/heap/HeapTest.cpp |
diff --git a/third_party/WebKit/Source/platform/heap/HeapTest.cpp b/third_party/WebKit/Source/platform/heap/HeapTest.cpp |
index 301efe469efd2ddaf6d639c9269991f053275b20..72e5901b3e9dcc8c05fd1c47b18d832647915a42 100644 |
--- a/third_party/WebKit/Source/platform/heap/HeapTest.cpp |
+++ b/third_party/WebKit/Source/platform/heap/HeapTest.cpp |
@@ -6509,4 +6509,25 @@ TEST(HeapTest, TestPersistentHeapVectorWithUnusedSlots) |
#endif |
} |
+TEST(HeapTest, TestStaticLocals) |
+{ |
+ // Sanity check DEFINE_STATIC_LOCAL()s over heap allocated objects and collections. |
+ |
+ DEFINE_STATIC_LOCAL(IntWrapper, intWrapper, (new IntWrapper(33))); |
+ DEFINE_STATIC_LOCAL(PersistentHeapVector<Member<IntWrapper>>, persistentHeapVectorIntWrapper, ()); |
+ DEFINE_STATIC_LOCAL(HeapVector<Member<IntWrapper>>, heapVectorIntWrapper, (new HeapVector<Member<IntWrapper>>)); |
+ |
+ EXPECT_EQ(33, intWrapper.value()); |
+ EXPECT_EQ(0u, persistentHeapVectorIntWrapper.size()); |
+ EXPECT_EQ(0u, heapVectorIntWrapper.size()); |
+ |
+ persistentHeapVectorIntWrapper.append(&intWrapper); |
+ heapVectorIntWrapper.append(&intWrapper); |
+ EXPECT_EQ(1u, persistentHeapVectorIntWrapper.size()); |
+ EXPECT_EQ(1u, heapVectorIntWrapper.size()); |
+ |
+ EXPECT_EQ(persistentHeapVectorIntWrapper[0], heapVectorIntWrapper[0]); |
+ EXPECT_EQ(33, heapVectorIntWrapper[0]->value()); |
+} |
+ |
} // namespace blink |