Bug 1329319 - gtest for issue with NewRunnableMethod on a non-refcounted base class method - r=froydnj
☠☠ backed out by f4787fd43910 ☠ ☠
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 09 Jan 2017 11:09:59 +1100
changeset 328603 ae96a44e6a8f517fbba92a349d26e67abd6a7499
parent 328602 a75ecabf7129af330c58aa4ab45c25d6dbf2a6b9
child 328604 f4787fd439103cf87ed3769e348a5576b2b3b9cb
push id35842
push usergsquelart@mozilla.com
push dateMon, 09 Jan 2017 23:39:48 +0000
treeherderautoland@ae96a44e6a8f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1329319
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
xpcom/glue/tests/gtest/TestThreadUtils.cpp
--- a/xpcom/glue/tests/gtest/TestThreadUtils.cpp
+++ b/xpcom/glue/tests/gtest/TestThreadUtils.cpp
@@ -175,17 +175,23 @@ public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFOO_IID)
 
   NS_IMETHOD_(nsrefcnt) RefCnt() = 0;
   NS_IMETHOD_(int32_t) ID() = 0;
 };
 
 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
 
   // IThreadUtilsObject implementation
   NS_IMETHOD_(nsrefcnt) RefCnt() override { return mRefCnt; }
   NS_IMETHOD_(int32_t) ID() override { return 0; }
 
@@ -369,16 +375,22 @@ TEST(ThreadUtils, main)
   r1->Run();
   EXPECT_EQ(count += 1, rpt->mCount);
 
   r1 = NewRunnableMethod<int>(rpt, &ThreadUtilsObject::Test1i, 11);
   r1->Run();
   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);
   r1->Run();
   EXPECT_EQ(count += 1, rpt->mCount);
 
   static_assert(
       mozilla::IsSame< ::detail::ParameterStorage<int>::Type,