Bug 996508 - Don't deliver async messages which were already received. r=smaug
☠☠ backed out by 6810499bd649 ☠ ☠
authorHenry Chang <hchang@mozilla.com>
Wed, 16 Apr 2014 11:38:15 +0800
changeset 180945 c2c65691e01d79b1d7b258494c81276221fa01c1
parent 180944 1201268ce09031a7fb284e9c6c171a8712b9e2d4
child 180946 2fac94005f866f86901203dace773c262f325cc8
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerssmaug
bugs996508
milestone31.0a1
Bug 996508 - Don't deliver async messages which were already received. r=smaug
content/base/src/nsFrameMessageManager.cpp
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -1769,28 +1769,35 @@ class nsAsyncMessageToSameProcessParent 
 {
 public:
   nsAsyncMessageToSameProcessParent(JSContext* aCx,
                                     const nsAString& aMessage,
                                     const StructuredCloneData& aData,
                                     JS::Handle<JSObject *> aCpows,
                                     nsIPrincipal* aPrincipal)
     : nsSameProcessAsyncMessageBase(aCx, aMessage, aData, aCpows, aPrincipal)
+    , mDelivered(false)
   {
   }
 
   NS_IMETHOD Run()
   {
     if (nsFrameMessageManager::sPendingSameProcessAsyncMessages) {
       nsFrameMessageManager::sPendingSameProcessAsyncMessages->RemoveElement(this);
     }
-    nsFrameMessageManager* ppm = nsFrameMessageManager::sSameProcessParentManager;
-    ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm), ppm);
+    if (!mDelivered) {
+      mDelivered = true;
+      nsFrameMessageManager* ppm = nsFrameMessageManager::sSameProcessParentManager;
+      ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm), ppm);
+    }
     return NS_OK;
   }
+
+private:
+  bool mDelivered;
 };
 
 /**
  * Send messages to the imaginary parent process in a single-process scenario.
  */
 class SameChildProcessMessageManagerCallback : public MessageManagerCallback
 {
 public: