Bug 1329319 - gtest for issue with NewRunnableMethod on a non-refcounted base class method - r=froydnj

This test alone would fail to even build without the previous patch,
demonstrating the issue at hand, where the method-pointer from the base class
forces NewRunnableMethod to store a pointer to that base class in a RefPtr,
which is not possible when that base class is not ref-counted.

MozReview-Commit-ID: 9XaQ8SwMqVo

--HG--
extra : rebase_source : 3ba0e13fb76ef2c5969084334c2f11e3f445d11f
This commit is contained in:
Gerald Squelart 2017-01-09 11:09:59 +11:00
parent 1cc4e2c254
commit 86723427e8

View File

@ -180,7 +180,13 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(IThreadUtilsObject, NS_IFOO_IID)
struct ThreadUtilsObjectNonRefCountedBase
{
virtual void MethodFromNonRefCountedBase() {}
};
struct ThreadUtilsObject : public IThreadUtilsObject
, public ThreadUtilsObjectNonRefCountedBase
{
// nsISupports implementation
NS_DECL_ISUPPORTS
@ -374,6 +380,12 @@ TEST(ThreadUtils, main)
EXPECT_EQ(count += 2, rpt->mCount);
EXPECT_EQ(11, rpt->mA0);
// Test calling a method from a non-ref-counted base.
r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::MethodFromNonRefCountedBase);
r1->Run();
EXPECT_EQ(count, rpt->mCount);
// Test variadic function with simple POD arguments.
r1 = NewRunnableMethod(rpt, &ThreadUtilsObject::Test0);