Bug 1481350 - Don't try to handle messages sent to child-allocated browsers, r=froydnj.
authorBrian Hackett <bhackett1024@gmail.com>
Tue, 21 Aug 2018 00:54:40 +0000
changeset 432642 8049cc4321284827bd54a40893bc529eba1b7b11
parent 432641 d0e40284db4b4f5851e23bb0e4a406e6f8e2ac5f
child 432643 83c0cdea8a9fb6dafe8a646145cc63582772cb8e
push id34482
push usertoros@mozilla.com
push dateTue, 21 Aug 2018 21:56:56 +0000
treeherdermozilla-central@7c96ad3ab673 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1481350
milestone63.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 1481350 - Don't try to handle messages sent to child-allocated browsers, r=froydnj.
toolkit/recordreplay/ipc/ParentForwarding.cpp
--- a/toolkit/recordreplay/ipc/ParentForwarding.cpp
+++ b/toolkit/recordreplay/ipc/ParentForwarding.cpp
@@ -112,18 +112,38 @@ HandleMessageInMiddleman(ipc::Side aSide
       type == dom::PBrowser::Msg_LoadURL__ID ||
       type == dom::PBrowser::Msg_Show__ID ||
       // May be loading devtools code that runs in the middleman process.
       type == dom::PBrowser::Msg_LoadRemoteScript__ID ||
       // May be sending a message for receipt by devtools code.
       type == dom::PBrowser::Msg_AsyncMessage__ID ||
       // Teardown that must be performed in both processes.
       type == dom::PBrowser::Msg_Destroy__ID) {
-    ipc::IProtocol::Result r =
-      dom::ContentChild::GetSingleton()->PContentChild::OnMessageReceived(aMessage);
+    dom::ContentChild* contentChild = dom::ContentChild::GetSingleton();
+
+    if (type >= dom::PBrowser::PBrowserStart && type <= dom::PBrowser::PBrowserEnd) {
+      // Ignore messages sent from the parent to browsers that do not have an
+      // actor in the middleman process. PBrowser may be allocated on either
+      // side of the IPDL channel, and when allocated by the recording child
+      // there will not be a corresponding actor in the middleman.
+      nsTArray<dom::PBrowserChild*> browsers;
+      contentChild->ManagedPBrowserChild(browsers);
+      bool found = false;
+      for (ipc::IProtocol* child : browsers) {
+        if (child->Id() == aMessage.routing_id()) {
+          found = true;
+          break;
+        }
+      }
+      if (!found) {
+        return false;
+      }
+    }
+
+    ipc::IProtocol::Result r = contentChild->PContentChild::OnMessageReceived(aMessage);
     MOZ_RELEASE_ASSERT(r == ipc::IProtocol::MsgProcessed);
     if (type == dom::PContent::Msg_SetXPCOMProcessAttributes__ID) {
       // Preferences are initialized via the SetXPCOMProcessAttributes message.
       PreferencesLoaded();
     }
     if (type == dom::PBrowser::Msg_Destroy__ID) {
       DestroyRoutingId(aMessage.routing_id());
     }