Index: Source/platform/heap/HeapTest.cpp |
diff --git a/Source/platform/heap/HeapTest.cpp b/Source/platform/heap/HeapTest.cpp |
index 5c93ea68e5a3d0207641dd5d8846a9288692f6cd..3a2fc82352eb5577309670aef54433018fc3fc6a 100644 |
--- a/Source/platform/heap/HeapTest.cpp |
+++ b/Source/platform/heap/HeapTest.cpp |
@@ -3978,4 +3978,24 @@ TEST(HeapTest, NeedsAdjustAndMark) |
EXPECT_FALSE(NeedsAdjustAndMark<const UseMixin>::value); |
} |
+TEST(HeapTest, Bind) |
+{ |
+ Closure closure = bind(&Bar::trace, Bar::create(), static_cast<Visitor*>(0)); |
+ Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
+ // The closure should have a persistent handle to the Bar. |
+ EXPECT_EQ(1u, Bar::s_live); |
+ |
+ Closure closure2 = bind(&Bar::trace, RawPtr<Bar>(Bar::create()), static_cast<Visitor*>(0)); |
+ Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
+ // The closure should have a persistent handle to the Bar. |
+ EXPECT_EQ(2u, Bar::s_live); |
+ |
+ UseMixin::s_traceCount = 0; |
+ Mixin* mixin = UseMixin::create(); |
+ Closure mixinClosure = bind(&Mixin::trace, mixin, static_cast<Visitor*>(0)); |
+ Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
+ // The closure should have a persistent handle to the mixin. |
+ EXPECT_EQ(1, UseMixin::s_traceCount); |
+} |
+ |
} // WebCore namespace |