Bug 1338635 - Declare |holder| before |atq| to ensure the destructor is run after |holder.Disconnect()|. r=gerald, a=test-only
authorJW Wang <jwwang@mozilla.com>
Mon, 29 May 2017 09:38:14 +0800
changeset 396445 cec923727fe67e7e8a8435b55b77bc05d633254f
parent 396444 fb25233dc2f4f12ea2ba99adfbfdd55ffc806881
child 396446 3772e7cf04c75ba3c7a000a15ee0439161ee77ba
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, test-only
bugs1338635
milestone54.0
Bug 1338635 - Declare |holder| before |atq| to ensure the destructor is run after |holder.Disconnect()|. r=gerald, a=test-only Otherwise we might fail the assertion |!mRequest| in the destructor of MozPromiseRequestHolder. MozReview-Commit-ID: HsVD2re0R7e
dom/media/gtest/TestMozPromise.cpp
--- a/dom/media/gtest/TestMozPromise.cpp
+++ b/dom/media/gtest/TestMozPromise.cpp
@@ -249,19 +249,22 @@ TEST(MozPromise, PromiseAllReject)
     );
   });
 }
 
 // Test we don't hit the assertions in MozPromise when exercising promise
 // chaining upon task queue shutdown.
 TEST(MozPromise, Chaining)
 {
+  // We declare this variable before |atq| to ensure
+  // the destructor is run after |holder.Disconnect()|.
+  MozPromiseRequestHolder<TestPromise> holder;
+
   AutoTaskQueue atq;
   RefPtr<TaskQueue> queue = atq.Queue();
-  MozPromiseRequestHolder<TestPromise> holder;
 
   RunOnTaskQueue(queue, [queue, &holder] () {
     auto p = TestPromise::CreateAndResolve(42, __func__);
     const size_t kIterations = 100;
     for (size_t i = 0; i < kIterations; ++i) {
       p = p->Then(queue, __func__,
         [] (int aVal) {
           EXPECT_EQ(aVal, 42);