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 d75c36deb5669fb103b82a34dd69ae696702640a..02fa6ee69b75c3ccc330171f678ce73645bfc95f 100644 |
--- a/third_party/WebKit/Source/platform/heap/HeapTest.cpp |
+++ b/third_party/WebKit/Source/platform/heap/HeapTest.cpp |
@@ -4568,11 +4568,17 @@ public: |
MixinA() : m_obj(IntWrapper::create(100)) { } |
DEFINE_INLINE_VIRTUAL_TRACE() |
{ |
+ s_traceCount++; |
visitor->trace(m_obj); |
} |
+ |
+ static int s_traceCount; |
+ |
Member<IntWrapper> m_obj; |
}; |
+int MixinA::s_traceCount = 0; |
+ |
class MixinB : public GarbageCollectedMixin { |
public: |
MixinB() : m_obj(IntWrapper::create(101)) { } |
@@ -4663,6 +4669,35 @@ TEST(HeapTest, DerivedMultipleMixins) |
EXPECT_EQ(4, IntWrapper::s_destructorCalls); |
} |
+class MixinInstanceWithoutTrace : public GarbageCollected<MixinInstanceWithoutTrace>, public MixinA { |
+ USING_GARBAGE_COLLECTED_MIXIN(MixinInstanceWithoutTrace); |
+public: |
+ MixinInstanceWithoutTrace() |
+ { |
+ } |
+}; |
+ |
+TEST(HeapTest, MixinInstanceWithoutTrace) |
+{ |
+ // Verify that a mixin instance without any traceable |
+ // references inherits the mixin's trace implementation. |
+ clearOutOldGarbage(); |
+ MixinA::s_traceCount = 0; |
+ MixinInstanceWithoutTrace* obj = new MixinInstanceWithoutTrace(); |
+ { |
+ Persistent<MixinA> a = obj; |
+ preciselyCollectGarbage(); |
+ EXPECT_EQ(1, MixinA::s_traceCount); |
+ } |
+ { |
+ Persistent<MixinInstanceWithoutTrace> b = obj; |
+ preciselyCollectGarbage(); |
+ EXPECT_EQ(2, MixinA::s_traceCount); |
+ } |
+ preciselyCollectGarbage(); |
+ EXPECT_EQ(2, MixinA::s_traceCount); |
+} |
+ |
class GCParkingThreadTester { |
public: |
static void test() |