Bug 1451973 - Split off process from non-process message managers. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Mon, 16 Apr 2018 15:18:48 +0200
changeset 477696 22e014e0bea4a4a87d23a48007c014e3a54b37cb
parent 477695 91627f5e19c7e5722405e8098f0084c394557593
child 477697 3567106d0a0505dc65477d2f43d67d1edbf46ba6
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1451973
milestone62.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 1451973 - Split off process from non-process message managers. r=bz. Process and non-process managers have different script loader interfaces (ProcessScriptLoader/GlobalProcessScriptLoader vs FrameScriptLoader). The WebIDL conversion used the same interface for some process and non-process managers, but because of the different script loader interfaces they really should be using separate interfaces.
dom/base/ChromeMessageBroadcaster.cpp
dom/base/ChromeMessageBroadcaster.h
dom/base/ChromeMessageSender.cpp
dom/base/ChromeMessageSender.h
dom/base/DocumentOrShadowRoot.h
dom/base/MessageBroadcaster.cpp
dom/base/MessageBroadcaster.h
dom/base/MessageListenerManager.cpp
dom/base/MessageListenerManager.h
dom/base/MessageManagerGlobal.h
dom/base/MessageSender.h
dom/base/MozQueryInterface.h
dom/base/NameSpaceConstants.h
dom/base/ParentProcessMessageManager.cpp
dom/base/ParentProcessMessageManager.h
dom/base/ProcessMessageManager.cpp
dom/base/ProcessMessageManager.h
dom/base/ShadowRoot.cpp
dom/base/StyleSheetList.cpp
dom/base/moz.build
dom/base/nsCCUncollectableMarker.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/base/nsDOMMutationObserver.cpp
dom/base/nsFrameLoader.cpp
dom/base/nsFrameLoader.h
dom/base/nsFrameMessageManager.cpp
dom/base/nsFrameMessageManager.h
dom/base/nsIdentifierMapEntry.h
dom/chrome-webidl/MessageManager.webidl
dom/ipc/ContentBridgeParent.cpp
dom/ipc/ContentParent.cpp
dom/ipc/nsIContentParent.cpp
dom/ipc/nsIContentParent.h
layout/style/nsComputedDOMStyle.h
--- a/dom/base/ChromeMessageBroadcaster.cpp
+++ b/dom/base/ChromeMessageBroadcaster.cpp
@@ -2,70 +2,24 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/ChromeMessageBroadcaster.h"
 #include "AccessCheck.h"
 #include "mozilla/HoldDropJSObjects.h"
-#include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/MessageManagerBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-ChromeMessageBroadcaster::ChromeMessageBroadcaster(ChromeMessageBroadcaster* aParentManager,
-                                                   MessageManagerFlags aFlags)
-  : MessageListenerManager(nullptr, aParentManager,
-                           aFlags |
-                           MessageManagerFlags::MM_BROADCASTER |
-                           MessageManagerFlags::MM_CHROME)
-{
-  if (mIsProcessManager) {
-    mozilla::HoldJSObjects(this);
-  }
-  if (aParentManager) {
-    aParentManager->AddChildManager(this);
-  }
-}
-
-ChromeMessageBroadcaster::~ChromeMessageBroadcaster()
-{
-  if (mIsProcessManager) {
-    mozilla::DropJSObjects(this);
-  }
-}
-
 JSObject*
 ChromeMessageBroadcaster::WrapObject(JSContext* aCx,
                                      JS::Handle<JSObject*> aGivenProto)
 {
   MOZ_ASSERT(nsContentUtils::IsSystemCaller(aCx));
 
   return ChromeMessageBroadcasterBinding::Wrap(aCx, this, aGivenProto);
 }
 
-void
-ChromeMessageBroadcaster::ReleaseCachedProcesses()
-{
-  ContentParent::ReleaseCachedProcesses();
-}
-
-void
-ChromeMessageBroadcaster::AddChildManager(MessageListenerManager* aManager)
-{
-  mChildManagers.AppendElement(aManager);
-
-  RefPtr<nsFrameMessageManager> kungfuDeathGrip = this;
-  RefPtr<nsFrameMessageManager> kungfuDeathGrip2 = aManager;
-
-  LoadPendingScripts(this, aManager);
-}
-
-void
-ChromeMessageBroadcaster::RemoveChildManager(MessageListenerManager* aManager)
-{
-  mChildManagers.RemoveElement(aManager);
-}
-
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/ChromeMessageBroadcaster.h
+++ b/dom/base/ChromeMessageBroadcaster.h
@@ -2,84 +2,41 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_ChromeMessageBroadcaster_h
 #define mozilla_dom_ChromeMessageBroadcaster_h
 
-#include "mozilla/dom/MessageListenerManager.h"
+#include "mozilla/dom/MessageBroadcaster.h"
 
 namespace mozilla {
 namespace dom {
 
-class ChromeMessageBroadcaster final : public MessageListenerManager
+/**
+ * Implementation for the WebIDL ChromeMessageBroadcaster interface. Used for window and
+ * group message managers.
+ */
+class ChromeMessageBroadcaster final : public MessageBroadcaster
 {
 public:
   explicit ChromeMessageBroadcaster(MessageManagerFlags aFlags)
     : ChromeMessageBroadcaster(nullptr, aFlags)
   {
     MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL |
-                            MessageManagerFlags::MM_PROCESSMANAGER |
                             MessageManagerFlags::MM_OWNSCALLBACK)));
   }
-  explicit ChromeMessageBroadcaster(ChromeMessageBroadcaster* aParentManager)
+  explicit ChromeMessageBroadcaster(MessageBroadcaster* aParentManager)
     : ChromeMessageBroadcaster(aParentManager, MessageManagerFlags::MM_NONE)
   {}
 
-  static ChromeMessageBroadcaster* From(nsFrameMessageManager* aManager)
-  {
-    if (aManager->IsBroadcaster() && aManager->IsChrome()) {
-      return static_cast<ChromeMessageBroadcaster*>(aManager);
-    }
-    return nullptr;
-  }
-
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
-  void BroadcastAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
-                             JS::Handle<JS::Value> aObj,
-                             JS::Handle<JSObject*> aObjects,
-                             mozilla::ErrorResult& aError)
-  {
-    DispatchAsyncMessage(aCx, aMessageName, aObj, aObjects, nullptr,
-                         JS::UndefinedHandleValue, aError);
-  }
-  uint32_t ChildCount()
-  {
-    return mChildManagers.Length();
-  }
-  MessageListenerManager* GetChildAt(uint32_t aIndex)
-  {
-    return mChildManagers.SafeElementAt(aIndex);
-  }
-  void ReleaseCachedProcesses();
-
-  // ProcessScriptLoader
-  void LoadProcessScript(const nsAString& aUrl, bool aAllowDelayedLoad,
-                         mozilla::ErrorResult& aError)
-  {
-    LoadScript(aUrl, aAllowDelayedLoad, false, aError);
-  }
-  void RemoveDelayedProcessScript(const nsAString& aURL)
-  {
-    RemoveDelayedScript(aURL);
-  }
-  void GetDelayedProcessScripts(JSContext* aCx,
-                                nsTArray<nsTArray<JS::Value>>& aScripts,
-                                mozilla::ErrorResult& aError)
-  {
-    GetDelayedScripts(aCx, aScripts, aError);
-  }
-
-  // GlobalProcessScriptLoader
-  using nsFrameMessageManager::GetInitialProcessData;
-
   // FrameScriptLoader
   void LoadFrameScript(const nsAString& aUrl, bool aAllowDelayedLoad,
                        bool aRunInGlobalScope, mozilla::ErrorResult& aError)
   {
     LoadScript(aUrl, aAllowDelayedLoad, aRunInGlobalScope, aError);
   }
   void RemoveDelayedFrameScript(const nsAString& aURL)
   {
@@ -87,21 +44,21 @@ public:
   }
   void GetDelayedFrameScripts(JSContext* aCx,
                               nsTArray<nsTArray<JS::Value>>& aScripts,
                               mozilla::ErrorResult& aError)
   {
     GetDelayedScripts(aCx, aScripts, aError);
   }
 
-  void AddChildManager(MessageListenerManager* aManager);
-  void RemoveChildManager(MessageListenerManager* aManager);
-
 private:
-  ChromeMessageBroadcaster(ChromeMessageBroadcaster* aParentManager,
-                           MessageManagerFlags aFlags);
-  virtual ~ChromeMessageBroadcaster();
+  ChromeMessageBroadcaster(MessageBroadcaster* aParentManager,
+                           MessageManagerFlags aFlags)
+    : MessageBroadcaster(aParentManager,
+                         aFlags |
+                         MessageManagerFlags::MM_CHROME)
+  {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_ChromeMessageBroadcaster_h
--- a/dom/base/ChromeMessageSender.cpp
+++ b/dom/base/ChromeMessageSender.cpp
@@ -5,34 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/ChromeMessageSender.h"
 #include "mozilla/dom/MessageManagerBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-ChromeMessageSender::ChromeMessageSender(ipc::MessageManagerCallback* aCallback,
-                                         ChromeMessageBroadcaster* aParentManager,
-                                         MessageManagerFlags aFlags)
-  : MessageSender(aCallback, aParentManager, aFlags | MessageManagerFlags::MM_CHROME)
-{
-  MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL |
-                          MessageManagerFlags::MM_PROCESSMANAGER |
-                          MessageManagerFlags::MM_OWNSCALLBACK)));
-
-  // This is a bit hackish. We attach to the parent, but only if we have a callback. We
-  // don't have a callback for the frame message manager, and for parent process message
-  // managers (except the parent in-process message manager). In those cases we wait until
-  // the child process is running (see MessageSender::InitWithCallback).
-  if (aParentManager && mCallback) {
-    aParentManager->AddChildManager(this);
-  }
-}
-
 JSObject*
 ChromeMessageSender::WrapObject(JSContext* aCx,
                                 JS::Handle<JSObject*> aGivenProto)
 {
   MOZ_ASSERT(nsContentUtils::IsSystemCaller(aCx));
 
   return ChromeMessageSenderBinding::Wrap(aCx, this, aGivenProto);
 }
--- a/dom/base/ChromeMessageSender.h
+++ b/dom/base/ChromeMessageSender.h
@@ -7,45 +7,31 @@
 #ifndef mozilla_dom_ChromeMessageSender_h
 #define mozilla_dom_ChromeMessageSender_h
 
 #include "mozilla/dom/MessageSender.h"
 
 namespace mozilla {
 namespace dom {
 
-class ChromeMessageBroadcaster;
+class MessageBroadcaster;
 
 class ChromeMessageSender final : public MessageSender
 {
 public:
-  ChromeMessageSender(ipc::MessageManagerCallback* aCallback,
-                      ChromeMessageBroadcaster* aParentManager,
-                      MessageManagerFlags aFlags=MessageManagerFlags::MM_NONE);
+  explicit ChromeMessageSender(MessageBroadcaster* aParentManager)
+    : MessageSender(nullptr, aParentManager, MessageManagerFlags::MM_CHROME)
+  {
+    // This is a bit hackish, we wait until the child process is running before attaching
+    // to the parent manager (see MessageSender::InitWithCallback).
+  }
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
-  // ProcessScriptLoader
-  void LoadProcessScript(const nsAString& aUrl, bool aAllowDelayedLoad,
-                         mozilla::ErrorResult& aError)
-  {
-    LoadScript(aUrl, aAllowDelayedLoad, false, aError);
-  }
-  void RemoveDelayedProcessScript(const nsAString& aURL)
-  {
-    RemoveDelayedScript(aURL);
-  }
-  void GetDelayedProcessScripts(JSContext* aCx,
-                                nsTArray<nsTArray<JS::Value>>& aScripts,
-                                mozilla::ErrorResult& aError)
-  {
-    GetDelayedScripts(aCx, aScripts, aError);
-  }
-
   // FrameScriptLoader
   void LoadFrameScript(const nsAString& aUrl, bool aAllowDelayedLoad,
                        bool aRunInGlobalScope, mozilla::ErrorResult& aError)
   {
     LoadScript(aUrl, aAllowDelayedLoad, aRunInGlobalScope, aError);
   }
   void RemoveDelayedFrameScript(const nsAString& aURL)
   {
--- a/dom/base/DocumentOrShadowRoot.h
+++ b/dom/base/DocumentOrShadowRoot.h
@@ -8,23 +8,25 @@
 #define mozilla_dom_DocumentOrShadowRoot_h__
 
 #include "mozilla/dom/NameSpaceConstants.h"
 #include "nsContentListDeclarations.h"
 #include "nsTArray.h"
 #include "nsIdentifierMapEntry.h"
 
 class nsContentList;
+class nsIDocument;
 class nsINode;
 
 namespace mozilla {
 class StyleSheet;
 
 namespace dom {
 
+class Element;
 class StyleSheetList;
 class ShadowRoot;
 
 /**
  * A class meant to be shared by ShadowRoot and Document, that holds a list of
  * stylesheets.
  *
  * TODO(emilio, bug 1418159): In the future this should hold most of the
copy from dom/base/ChromeMessageBroadcaster.cpp
copy to dom/base/MessageBroadcaster.cpp
--- a/dom/base/ChromeMessageBroadcaster.cpp
+++ b/dom/base/MessageBroadcaster.cpp
@@ -1,71 +1,48 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "mozilla/dom/ChromeMessageBroadcaster.h"
-#include "AccessCheck.h"
-#include "mozilla/HoldDropJSObjects.h"
+#include "mozilla/dom/MessageBroadcaster.h"
 #include "mozilla/dom/ContentParent.h"
-#include "mozilla/dom/MessageManagerBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-ChromeMessageBroadcaster::ChromeMessageBroadcaster(ChromeMessageBroadcaster* aParentManager,
-                                                   MessageManagerFlags aFlags)
+MessageBroadcaster::MessageBroadcaster(MessageBroadcaster* aParentManager,
+                                       MessageManagerFlags aFlags)
   : MessageListenerManager(nullptr, aParentManager,
                            aFlags |
-                           MessageManagerFlags::MM_BROADCASTER |
-                           MessageManagerFlags::MM_CHROME)
+                           MessageManagerFlags::MM_BROADCASTER)
 {
-  if (mIsProcessManager) {
-    mozilla::HoldJSObjects(this);
-  }
   if (aParentManager) {
     aParentManager->AddChildManager(this);
   }
 }
 
-ChromeMessageBroadcaster::~ChromeMessageBroadcaster()
-{
-  if (mIsProcessManager) {
-    mozilla::DropJSObjects(this);
-  }
-}
-
-JSObject*
-ChromeMessageBroadcaster::WrapObject(JSContext* aCx,
-                                     JS::Handle<JSObject*> aGivenProto)
-{
-  MOZ_ASSERT(nsContentUtils::IsSystemCaller(aCx));
-
-  return ChromeMessageBroadcasterBinding::Wrap(aCx, this, aGivenProto);
-}
-
 void
-ChromeMessageBroadcaster::ReleaseCachedProcesses()
+MessageBroadcaster::ReleaseCachedProcesses()
 {
   ContentParent::ReleaseCachedProcesses();
 }
 
 void
-ChromeMessageBroadcaster::AddChildManager(MessageListenerManager* aManager)
+MessageBroadcaster::AddChildManager(MessageListenerManager* aManager)
 {
   mChildManagers.AppendElement(aManager);
 
   RefPtr<nsFrameMessageManager> kungfuDeathGrip = this;
   RefPtr<nsFrameMessageManager> kungfuDeathGrip2 = aManager;
 
   LoadPendingScripts(this, aManager);
 }
 
 void
-ChromeMessageBroadcaster::RemoveChildManager(MessageListenerManager* aManager)
+MessageBroadcaster::RemoveChildManager(MessageListenerManager* aManager)
 {
   mChildManagers.RemoveElement(aManager);
 }
 
 } // namespace dom
 } // namespace mozilla
copy from dom/base/ChromeMessageBroadcaster.h
copy to dom/base/MessageBroadcaster.h
--- a/dom/base/ChromeMessageBroadcaster.h
+++ b/dom/base/MessageBroadcaster.h
@@ -1,47 +1,37 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef mozilla_dom_ChromeMessageBroadcaster_h
-#define mozilla_dom_ChromeMessageBroadcaster_h
+#ifndef mozilla_dom_MessageBroadcaster_h
+#define mozilla_dom_MessageBroadcaster_h
 
 #include "mozilla/dom/MessageListenerManager.h"
 
 namespace mozilla {
 namespace dom {
 
-class ChromeMessageBroadcaster final : public MessageListenerManager
+/**
+ * Implementation for the WebIDL MessageBroadcaster interface. Base class for window and
+ * process broadcaster message managers.
+ */
+class MessageBroadcaster : public MessageListenerManager
 {
 public:
-  explicit ChromeMessageBroadcaster(MessageManagerFlags aFlags)
-    : ChromeMessageBroadcaster(nullptr, aFlags)
+  static MessageBroadcaster* From(MessageListenerManager* aManager)
   {
-    MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL |
-                            MessageManagerFlags::MM_PROCESSMANAGER |
-                            MessageManagerFlags::MM_OWNSCALLBACK)));
-  }
-  explicit ChromeMessageBroadcaster(ChromeMessageBroadcaster* aParentManager)
-    : ChromeMessageBroadcaster(aParentManager, MessageManagerFlags::MM_NONE)
-  {}
-
-  static ChromeMessageBroadcaster* From(nsFrameMessageManager* aManager)
-  {
-    if (aManager->IsBroadcaster() && aManager->IsChrome()) {
-      return static_cast<ChromeMessageBroadcaster*>(aManager);
+    if (aManager->IsBroadcaster()) {
+      return static_cast<MessageBroadcaster*>(aManager);
     }
     return nullptr;
   }
 
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aGivenProto) override;
-
   void BroadcastAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
                              JS::Handle<JS::Value> aObj,
                              JS::Handle<JSObject*> aObjects,
                              mozilla::ErrorResult& aError)
   {
     DispatchAsyncMessage(aCx, aMessageName, aObj, aObjects, nullptr,
                          JS::UndefinedHandleValue, aError);
   }
@@ -50,58 +40,19 @@ public:
     return mChildManagers.Length();
   }
   MessageListenerManager* GetChildAt(uint32_t aIndex)
   {
     return mChildManagers.SafeElementAt(aIndex);
   }
   void ReleaseCachedProcesses();
 
-  // ProcessScriptLoader
-  void LoadProcessScript(const nsAString& aUrl, bool aAllowDelayedLoad,
-                         mozilla::ErrorResult& aError)
-  {
-    LoadScript(aUrl, aAllowDelayedLoad, false, aError);
-  }
-  void RemoveDelayedProcessScript(const nsAString& aURL)
-  {
-    RemoveDelayedScript(aURL);
-  }
-  void GetDelayedProcessScripts(JSContext* aCx,
-                                nsTArray<nsTArray<JS::Value>>& aScripts,
-                                mozilla::ErrorResult& aError)
-  {
-    GetDelayedScripts(aCx, aScripts, aError);
-  }
-
-  // GlobalProcessScriptLoader
-  using nsFrameMessageManager::GetInitialProcessData;
-
-  // FrameScriptLoader
-  void LoadFrameScript(const nsAString& aUrl, bool aAllowDelayedLoad,
-                       bool aRunInGlobalScope, mozilla::ErrorResult& aError)
-  {
-    LoadScript(aUrl, aAllowDelayedLoad, aRunInGlobalScope, aError);
-  }
-  void RemoveDelayedFrameScript(const nsAString& aURL)
-  {
-    RemoveDelayedScript(aURL);
-  }
-  void GetDelayedFrameScripts(JSContext* aCx,
-                              nsTArray<nsTArray<JS::Value>>& aScripts,
-                              mozilla::ErrorResult& aError)
-  {
-    GetDelayedScripts(aCx, aScripts, aError);
-  }
-
   void AddChildManager(MessageListenerManager* aManager);
   void RemoveChildManager(MessageListenerManager* aManager);
 
-private:
-  ChromeMessageBroadcaster(ChromeMessageBroadcaster* aParentManager,
-                           MessageManagerFlags aFlags);
-  virtual ~ChromeMessageBroadcaster();
+protected:
+  MessageBroadcaster(MessageBroadcaster* aParentManager, MessageManagerFlags aFlags);
 };
 
 } // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_dom_ChromeMessageBroadcaster_h
+#endif // mozilla_dom_MessageBroadcaster_h
--- a/dom/base/MessageListenerManager.cpp
+++ b/dom/base/MessageListenerManager.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/MessageListenerManager.h"
 
 namespace mozilla {
 namespace dom {
 
 MessageListenerManager::MessageListenerManager(ipc::MessageManagerCallback* aCallback,
-                                               ChromeMessageBroadcaster* aParentManager,
+                                               MessageBroadcaster* aParentManager,
                                                ipc::MessageManagerFlags aFlags)
   : nsFrameMessageManager(aCallback, aFlags),
     mParentManager(aParentManager)
 {
 }
 
 MessageListenerManager::~MessageListenerManager()
 {
--- a/dom/base/MessageListenerManager.h
+++ b/dom/base/MessageListenerManager.h
@@ -9,45 +9,51 @@
 
 #include "nsCycleCollectionNoteChild.h"
 #include "nsFrameMessageManager.h"
 #include "nsWrapperCache.h"
 
 namespace mozilla {
 namespace dom {
 
+class MessageBroadcaster;
+
+/**
+ * Implementation for the WebIDL MessageListenerManager interface. Base class for message
+ * managers that are exposed to script.
+ */
 class MessageListenerManager : public nsFrameMessageManager,
                                public nsWrapperCache
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageListenerManager,
                                                          nsFrameMessageManager)
 
-  ChromeMessageBroadcaster* GetParentObject()
+  MessageBroadcaster* GetParentObject()
   {
     return mParentManager;
   }
 
-  virtual ChromeMessageBroadcaster* GetParentManager() override
+  virtual MessageBroadcaster* GetParentManager() override
   {
     return mParentManager;
   }
 
   /**
    * If aRemove is true then RemoveChildManager(this) will be called on the parent manager
    * first.
    */
   virtual void ClearParentManager(bool aRemove) override;
 
 protected:
   MessageListenerManager(ipc::MessageManagerCallback* aCallback,
-                         ChromeMessageBroadcaster* aParentManager,
+                         MessageBroadcaster* aParentManager,
                          MessageManagerFlags aFlags);
   virtual ~MessageListenerManager();
 
-  RefPtr<ChromeMessageBroadcaster> mParentManager;
+  RefPtr<MessageBroadcaster> mParentManager;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_MessageListenerManager_h
--- a/dom/base/MessageManagerGlobal.h
+++ b/dom/base/MessageManagerGlobal.h
@@ -73,17 +73,17 @@ public:
   {
     if (!mMessageManager) {
       aError.Throw(NS_ERROR_NULL_POINTER);
       return;
     }
     mMessageManager->SendAsyncMessage(aCx, aMessageName, aObj, aObjects,
                                       aPrincipal, aTransfers, aError);
   }
-  already_AddRefed<ChromeMessageSender> GetProcessMessageManager(mozilla::ErrorResult& aError)
+  already_AddRefed<ProcessMessageManager> GetProcessMessageManager(mozilla::ErrorResult& aError)
   {
     if (!mMessageManager) {
       aError.Throw(NS_ERROR_NULL_POINTER);
       return nullptr;
     }
     return mMessageManager->GetProcessMessageManager(aError);
   }
 
--- a/dom/base/MessageSender.h
+++ b/dom/base/MessageSender.h
@@ -7,24 +7,30 @@
 #ifndef mozilla_dom_MessageSender_h
 #define mozilla_dom_MessageSender_h
 
 #include "mozilla/dom/MessageListenerManager.h"
 
 namespace mozilla {
 namespace dom {
 
+class MessageBroadcaster;
+
+/**
+ * Implementation for the WebIDL MessageSender interface. Base class for frame and child
+ * process message managers.
+ */
 class MessageSender : public MessageListenerManager
 {
 public:
   void InitWithCallback(ipc::MessageManagerCallback* aCallback);
 
 protected:
   MessageSender(ipc::MessageManagerCallback* aCallback,
-                ChromeMessageBroadcaster* aParentManager,
+                MessageBroadcaster* aParentManager,
                 MessageManagerFlags aFlags)
     : MessageListenerManager(aCallback, aParentManager, aFlags)
   {}
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/base/MozQueryInterface.h
+++ b/dom/base/MozQueryInterface.h
@@ -15,18 +15,19 @@
  * returning its `this` object or throwing depending on the interface it was
  * passed.
  *
  * For native XPConnect callers, we bypass JSAPI entirely, and directly check
  * whether the queried interface is in the interfaces list.
  */
 
 #include "mozilla/dom/BindingDeclarations.h"
-#include "mozilla/dom/ChromeUtilsBinding.h"
+#include "mozilla/dom/NonRefcountedDOMObject.h"
 #include "mozilla/ErrorResult.h"
+#include "nsID.h"
 
 namespace mozilla {
 namespace dom {
 
 class MozQueryInterface final : public NonRefcountedDOMObject
 {
 public:
   explicit MozQueryInterface(nsTArray<nsIID>&& aInterfaces)
--- a/dom/base/NameSpaceConstants.h
+++ b/dom/base/NameSpaceConstants.h
@@ -2,16 +2,18 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_NameSpaceConstants_h__
 #define mozilla_dom_NameSpaceConstants_h__
 
+#include <stdint.h>
+
 #define kNameSpaceID_Unknown -1
 // 0 is special at C++, so use a static const int32_t for
 // kNameSpaceID_None to keep if from being cast to pointers
 // Note that the XBL cache assumes (and asserts) that it can treat a
 // single-byte value higher than kNameSpaceID_LastBuiltin specially.
 static const int32_t kNameSpaceID_None = 0;
 #define kNameSpaceID_XMLNS    1 // not really a namespace, but it needs to play the game
 #define kNameSpaceID_XML      2
copy from dom/base/ChromeMessageBroadcaster.cpp
copy to dom/base/ParentProcessMessageManager.cpp
--- a/dom/base/ChromeMessageBroadcaster.cpp
+++ b/dom/base/ParentProcessMessageManager.cpp
@@ -1,71 +1,38 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "mozilla/dom/ChromeMessageBroadcaster.h"
+#include "mozilla/dom/ParentProcessMessageManager.h"
 #include "AccessCheck.h"
 #include "mozilla/HoldDropJSObjects.h"
-#include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/MessageManagerBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-ChromeMessageBroadcaster::ChromeMessageBroadcaster(ChromeMessageBroadcaster* aParentManager,
-                                                   MessageManagerFlags aFlags)
-  : MessageListenerManager(nullptr, aParentManager,
-                           aFlags |
-                           MessageManagerFlags::MM_BROADCASTER |
-                           MessageManagerFlags::MM_CHROME)
+ParentProcessMessageManager::ParentProcessMessageManager()
+  : MessageBroadcaster(nullptr,
+                       MessageManagerFlags::MM_CHROME |
+                       MessageManagerFlags::MM_PROCESSMANAGER)
 {
-  if (mIsProcessManager) {
-    mozilla::HoldJSObjects(this);
-  }
-  if (aParentManager) {
-    aParentManager->AddChildManager(this);
-  }
+  mozilla::HoldJSObjects(this);
 }
 
-ChromeMessageBroadcaster::~ChromeMessageBroadcaster()
+ParentProcessMessageManager::~ParentProcessMessageManager()
 {
-  if (mIsProcessManager) {
-    mozilla::DropJSObjects(this);
-  }
+  mozilla::DropJSObjects(this);
 }
 
 JSObject*
-ChromeMessageBroadcaster::WrapObject(JSContext* aCx,
-                                     JS::Handle<JSObject*> aGivenProto)
+ParentProcessMessageManager::WrapObject(JSContext* aCx,
+                                        JS::Handle<JSObject*> aGivenProto)
 {
   MOZ_ASSERT(nsContentUtils::IsSystemCaller(aCx));
 
-  return ChromeMessageBroadcasterBinding::Wrap(aCx, this, aGivenProto);
-}
-
-void
-ChromeMessageBroadcaster::ReleaseCachedProcesses()
-{
-  ContentParent::ReleaseCachedProcesses();
-}
-
-void
-ChromeMessageBroadcaster::AddChildManager(MessageListenerManager* aManager)
-{
-  mChildManagers.AppendElement(aManager);
-
-  RefPtr<nsFrameMessageManager> kungfuDeathGrip = this;
-  RefPtr<nsFrameMessageManager> kungfuDeathGrip2 = aManager;
-
-  LoadPendingScripts(this, aManager);
-}
-
-void
-ChromeMessageBroadcaster::RemoveChildManager(MessageListenerManager* aManager)
-{
-  mChildManagers.RemoveElement(aManager);
+  return ParentProcessMessageManagerBinding::Wrap(aCx, this, aGivenProto);
 }
 
 } // namespace dom
 } // namespace mozilla
copy from dom/base/ChromeMessageBroadcaster.h
copy to dom/base/ParentProcessMessageManager.h
--- a/dom/base/ChromeMessageBroadcaster.h
+++ b/dom/base/ParentProcessMessageManager.h
@@ -1,65 +1,35 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef mozilla_dom_ChromeMessageBroadcaster_h
-#define mozilla_dom_ChromeMessageBroadcaster_h
+#ifndef mozilla_dom_ParentProcessMessageManager_h
+#define mozilla_dom_ParentProcessMessageManager_h
 
-#include "mozilla/dom/MessageListenerManager.h"
+#include "mozilla/dom/MessageBroadcaster.h"
 
 namespace mozilla {
 namespace dom {
 
-class ChromeMessageBroadcaster final : public MessageListenerManager
+/**
+ * Implementation for the WebIDL ParentProcessMessageManager interface.
+ * ParentProcessMessageManager is used in a parent process to communicate with all the
+ * child processes.
+ */
+class ParentProcessMessageManager final : public MessageBroadcaster
 {
 public:
-  explicit ChromeMessageBroadcaster(MessageManagerFlags aFlags)
-    : ChromeMessageBroadcaster(nullptr, aFlags)
-  {
-    MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL |
-                            MessageManagerFlags::MM_PROCESSMANAGER |
-                            MessageManagerFlags::MM_OWNSCALLBACK)));
-  }
-  explicit ChromeMessageBroadcaster(ChromeMessageBroadcaster* aParentManager)
-    : ChromeMessageBroadcaster(aParentManager, MessageManagerFlags::MM_NONE)
-  {}
-
-  static ChromeMessageBroadcaster* From(nsFrameMessageManager* aManager)
-  {
-    if (aManager->IsBroadcaster() && aManager->IsChrome()) {
-      return static_cast<ChromeMessageBroadcaster*>(aManager);
-    }
-    return nullptr;
-  }
+  ParentProcessMessageManager();
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
-  void BroadcastAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
-                             JS::Handle<JS::Value> aObj,
-                             JS::Handle<JSObject*> aObjects,
-                             mozilla::ErrorResult& aError)
-  {
-    DispatchAsyncMessage(aCx, aMessageName, aObj, aObjects, nullptr,
-                         JS::UndefinedHandleValue, aError);
-  }
-  uint32_t ChildCount()
-  {
-    return mChildManagers.Length();
-  }
-  MessageListenerManager* GetChildAt(uint32_t aIndex)
-  {
-    return mChildManagers.SafeElementAt(aIndex);
-  }
-  void ReleaseCachedProcesses();
-
   // ProcessScriptLoader
   void LoadProcessScript(const nsAString& aUrl, bool aAllowDelayedLoad,
                          mozilla::ErrorResult& aError)
   {
     LoadScript(aUrl, aAllowDelayedLoad, false, aError);
   }
   void RemoveDelayedProcessScript(const nsAString& aURL)
   {
@@ -70,38 +40,16 @@ public:
                                 mozilla::ErrorResult& aError)
   {
     GetDelayedScripts(aCx, aScripts, aError);
   }
 
   // GlobalProcessScriptLoader
   using nsFrameMessageManager::GetInitialProcessData;
 
-  // FrameScriptLoader
-  void LoadFrameScript(const nsAString& aUrl, bool aAllowDelayedLoad,
-                       bool aRunInGlobalScope, mozilla::ErrorResult& aError)
-  {
-    LoadScript(aUrl, aAllowDelayedLoad, aRunInGlobalScope, aError);
-  }
-  void RemoveDelayedFrameScript(const nsAString& aURL)
-  {
-    RemoveDelayedScript(aURL);
-  }
-  void GetDelayedFrameScripts(JSContext* aCx,
-                              nsTArray<nsTArray<JS::Value>>& aScripts,
-                              mozilla::ErrorResult& aError)
-  {
-    GetDelayedScripts(aCx, aScripts, aError);
-  }
-
-  void AddChildManager(MessageListenerManager* aManager);
-  void RemoveChildManager(MessageListenerManager* aManager);
-
 private:
-  ChromeMessageBroadcaster(ChromeMessageBroadcaster* aParentManager,
-                           MessageManagerFlags aFlags);
-  virtual ~ChromeMessageBroadcaster();
+  virtual ~ParentProcessMessageManager();
 };
 
 } // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_dom_ChromeMessageBroadcaster_h
+#endif // mozilla_dom_ParentProcessMessageManager_h
copy from dom/base/ChromeMessageSender.cpp
copy to dom/base/ProcessMessageManager.cpp
--- a/dom/base/ChromeMessageSender.cpp
+++ b/dom/base/ProcessMessageManager.cpp
@@ -1,41 +1,41 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "mozilla/dom/ChromeMessageSender.h"
+#include "mozilla/dom/ProcessMessageManager.h"
 #include "mozilla/dom/MessageManagerBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-ChromeMessageSender::ChromeMessageSender(ipc::MessageManagerCallback* aCallback,
-                                         ChromeMessageBroadcaster* aParentManager,
-                                         MessageManagerFlags aFlags)
-  : MessageSender(aCallback, aParentManager, aFlags | MessageManagerFlags::MM_CHROME)
+ProcessMessageManager::ProcessMessageManager(ipc::MessageManagerCallback* aCallback,
+                                             ParentProcessMessageManager* aParentManager,
+                                             MessageManagerFlags aFlags)
+  : MessageSender(aCallback, aParentManager,
+                  aFlags | MessageManagerFlags::MM_CHROME |
+                           MessageManagerFlags::MM_PROCESSMANAGER)
 {
   MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL |
-                          MessageManagerFlags::MM_PROCESSMANAGER |
                           MessageManagerFlags::MM_OWNSCALLBACK)));
 
-  // This is a bit hackish. We attach to the parent, but only if we have a callback. We
-  // don't have a callback for the frame message manager, and for parent process message
-  // managers (except the parent in-process message manager). In those cases we wait until
-  // the child process is running (see MessageSender::InitWithCallback).
+  // This is a bit hackish. We attach to the parent manager, but only if we have a
+  // callback (which is only for the in-process message manager). For other cases we wait
+  // until the child process is running (see MessageSender::InitWithCallback).
   if (aParentManager && mCallback) {
     aParentManager->AddChildManager(this);
   }
 }
 
 JSObject*
-ChromeMessageSender::WrapObject(JSContext* aCx,
-                                JS::Handle<JSObject*> aGivenProto)
+ProcessMessageManager::WrapObject(JSContext* aCx,
+                                  JS::Handle<JSObject*> aGivenProto)
 {
   MOZ_ASSERT(nsContentUtils::IsSystemCaller(aCx));
 
-  return ChromeMessageSenderBinding::Wrap(aCx, this, aGivenProto);
+  return ProcessMessageManagerBinding::Wrap(aCx, this, aGivenProto);
 }
 
 } // namespace dom
 } // namespace mozilla
copy from dom/base/ChromeMessageSender.h
copy to dom/base/ProcessMessageManager.h
--- a/dom/base/ChromeMessageSender.h
+++ b/dom/base/ProcessMessageManager.h
@@ -1,30 +1,34 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef mozilla_dom_ChromeMessageSender_h
-#define mozilla_dom_ChromeMessageSender_h
+#ifndef mozilla_dom_ProcessMessageManager_h
+#define mozilla_dom_ProcessMessageManager_h
 
 #include "mozilla/dom/MessageSender.h"
 
 namespace mozilla {
 namespace dom {
 
-class ChromeMessageBroadcaster;
+class ParentProcessMessageManager;
 
-class ChromeMessageSender final : public MessageSender
+/**
+ * ProcessMessageManager is used in a parent process to communicate with a child process
+ * (or with the process itself in a single-process scenario).
+ */
+class ProcessMessageManager final : public MessageSender
 {
 public:
-  ChromeMessageSender(ipc::MessageManagerCallback* aCallback,
-                      ChromeMessageBroadcaster* aParentManager,
-                      MessageManagerFlags aFlags=MessageManagerFlags::MM_NONE);
+  ProcessMessageManager(ipc::MessageManagerCallback* aCallback,
+                        ParentProcessMessageManager* aParentManager,
+                        MessageManagerFlags aFlags=MessageManagerFlags::MM_NONE);
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
   // ProcessScriptLoader
   void LoadProcessScript(const nsAString& aUrl, bool aAllowDelayedLoad,
                          mozilla::ErrorResult& aError)
   {
@@ -35,31 +39,14 @@ public:
     RemoveDelayedScript(aURL);
   }
   void GetDelayedProcessScripts(JSContext* aCx,
                                 nsTArray<nsTArray<JS::Value>>& aScripts,
                                 mozilla::ErrorResult& aError)
   {
     GetDelayedScripts(aCx, aScripts, aError);
   }
-
-  // FrameScriptLoader
-  void LoadFrameScript(const nsAString& aUrl, bool aAllowDelayedLoad,
-                       bool aRunInGlobalScope, mozilla::ErrorResult& aError)
-  {
-    LoadScript(aUrl, aAllowDelayedLoad, aRunInGlobalScope, aError);
-  }
-  void RemoveDelayedFrameScript(const nsAString& aURL)
-  {
-    RemoveDelayedScript(aURL);
-  }
-  void GetDelayedFrameScripts(JSContext* aCx,
-                              nsTArray<nsTArray<JS::Value>>& aScripts,
-                              mozilla::ErrorResult& aError)
-  {
-    GetDelayedScripts(aCx, aScripts, aError);
-  }
 };
 
 } // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_dom_ChromeMessageSender_h
+#endif // mozilla_dom_ProcessMessageManager_h
--- a/dom/base/ShadowRoot.cpp
+++ b/dom/base/ShadowRoot.cpp
@@ -13,16 +13,17 @@
 #include "nsIStyleSheetLinkingElement.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/HTMLSlotElement.h"
 #include "nsXBLPrototypeBinding.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/ServoStyleRuleMap.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
+#include "mozilla/dom/StyleSheetList.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(ShadowRoot)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ShadowRoot, DocumentFragment)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStyleSheets)
--- a/dom/base/StyleSheetList.cpp
+++ b/dom/base/StyleSheetList.cpp
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/StyleSheetList.h"
 
 #include "mozilla/dom/StyleSheetListBinding.h"
+#include "nsINode.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(StyleSheetList)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StyleSheetList)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -185,27 +185,30 @@ EXPORTS.mozilla.dom += [
     'IdleDeadline.h',
     'IdleRequest.h',
     'IDTracker.h',
     'ImageEncoder.h',
     'ImageTracker.h',
     'IntlUtils.h',
     'Link.h',
     'Location.h',
+    'MessageBroadcaster.h',
     'MessageListenerManager.h',
     'MessageManagerGlobal.h',
     'MessageSender.h',
     'MozQueryInterface.h',
     'NameSpaceConstants.h',
     'Navigator.h',
     'NodeInfo.h',
     'NodeInfoInlines.h',
     'NodeIterator.h',
+    'ParentProcessMessageManager.h',
     'Pose.h',
     'ProcessGlobal.h',
+    'ProcessMessageManager.h',
     'ResponsiveImageSelector.h',
     'SameProcessMessageQueue.h',
     'ScreenOrientation.h',
     'Selection.h',
     'ShadowRoot.h',
     'StructuredCloneBlob.h',
     'StructuredCloneHolder.h',
     'StructuredCloneTags.h',
@@ -266,16 +269,17 @@ UNIFIED_SOURCES += [
     'IdleDeadline.cpp',
     'IdleRequest.cpp',
     'IDTracker.cpp',
     'ImageEncoder.cpp',
     'ImageTracker.cpp',
     'IntlUtils.cpp',
     'Link.cpp',
     'Location.cpp',
+    'MessageBroadcaster.cpp',
     'MessageListenerManager.cpp',
     'MessageManagerGlobal.cpp',
     'MessageSender.cpp',
     'MozQueryInterface.cpp',
     'Navigator.cpp',
     'NodeInfo.cpp',
     'NodeIterator.cpp',
     'nsAttrAndChildArray.cpp',
@@ -339,19 +343,21 @@ UNIFIED_SOURCES += [
     'nsTreeSanitizer.cpp',
     'nsViewportInfo.cpp',
     'nsWindowMemoryReporter.cpp',
     'nsWindowRoot.cpp',
     'nsWrapperCache.cpp',
     'nsXHTMLContentSerializer.cpp',
     'nsXMLContentSerializer.cpp',
     'nsXMLNameSpaceMap.cpp',
+    'ParentProcessMessageManager.cpp',
     'Pose.cpp',
     'PostMessageEvent.cpp',
     'ProcessGlobal.cpp',
+    'ProcessMessageManager.cpp',
     'ResponsiveImageSelector.cpp',
     'SameProcessMessageQueue.cpp',
     'ScreenOrientation.cpp',
     'Selection.cpp',
     'SelectionChangeListener.cpp',
     'ShadowRoot.cpp',
     'StructuredCloneBlob.cpp',
     'StructuredCloneHolder.cpp',
--- a/dom/base/nsCCUncollectableMarker.cpp
+++ b/dom/base/nsCCUncollectableMarker.cpp
@@ -25,17 +25,19 @@
 #include "nsContentUtils.h"
 #include "nsGlobalWindow.h"
 #include "nsJSEnvironment.h"
 #include "nsInProcessTabChildGlobal.h"
 #include "nsFrameLoader.h"
 #include "mozilla/CycleCollectedJSContext.h"
 #include "mozilla/CycleCollectedJSRuntime.h"
 #include "mozilla/EventListenerManager.h"
+#include "mozilla/dom/ChromeMessageBroadcaster.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/ParentProcessMessageManager.h"
 #include "mozilla/dom/ProcessGlobal.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/TimeoutManager.h"
 #include "xpcpublic.h"
 #include "nsObserverService.h"
 #include "nsFocusManager.h"
 #include "nsIInterfaceRequestorUtils.h"
 
@@ -81,30 +83,29 @@ nsCCUncollectableMarker::Init()
   NS_ENSURE_SUCCESS(rv, rv);
 
   sInited = true;
 
   return NS_OK;
 }
 
 static void
-MarkChildMessageManagers(ChromeMessageBroadcaster* aMM)
+MarkChildMessageManagers(MessageBroadcaster* aMM)
 {
   aMM->MarkForCC();
 
   uint32_t tabChildCount = aMM->ChildCount();
   for (uint32_t j = 0; j < tabChildCount; ++j) {
     RefPtr<MessageListenerManager> childMM = aMM->GetChildAt(j);
     if (!childMM) {
       continue;
     }
 
-    RefPtr<ChromeMessageBroadcaster> strongNonLeafMM =
-      ChromeMessageBroadcaster::From(childMM);
-    ChromeMessageBroadcaster* nonLeafMM = strongNonLeafMM;
+    RefPtr<MessageBroadcaster> strongNonLeafMM = MessageBroadcaster::From(childMM);
+    MessageBroadcaster* nonLeafMM = strongNonLeafMM;
 
     MessageListenerManager* tabMM = childMM;
 
     strongNonLeafMM = nullptr;
     childMM = nullptr;
 
     if (nonLeafMM) {
       MarkChildMessageManagers(nonLeafMM);
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -34,16 +34,17 @@
 #include "mozilla/AutoRestore.h"
 #include "mozilla/AutoTimelineMarker.h"
 #include "mozilla/Base64.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/CustomElementRegistry.h"
+#include "mozilla/dom/MessageBroadcaster.h"
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/DOMExceptionBinding.h"
 #include "mozilla/dom/DOMTypes.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ElementInlines.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/FileSystemSecurity.h"
@@ -7651,28 +7652,28 @@ nsContentUtils::GetHostOrIPv6WithBracket
   if (NS_FAILED(rv)) {
     return rv;
   }
   CopyUTF8toUTF16(hostname, aHost);
   return NS_OK;
 }
 
 bool
-nsContentUtils::CallOnAllRemoteChildren(ChromeMessageBroadcaster* aManager,
+nsContentUtils::CallOnAllRemoteChildren(MessageBroadcaster* aManager,
                                         CallOnRemoteChildFunction aCallback,
                                         void* aArg)
 {
   uint32_t tabChildCount = aManager->ChildCount();
   for (uint32_t j = 0; j < tabChildCount; ++j) {
     RefPtr<MessageListenerManager> childMM = aManager->GetChildAt(j);
     if (!childMM) {
       continue;
     }
 
-    RefPtr<ChromeMessageBroadcaster> nonLeafMM = ChromeMessageBroadcaster::From(childMM);
+    RefPtr<MessageBroadcaster> nonLeafMM = MessageBroadcaster::From(childMM);
     if (nonLeafMM) {
       if (CallOnAllRemoteChildren(nonLeafMM, aCallback, aArg)) {
         return true;
       }
       continue;
     }
 
     mozilla::dom::ipc::MessageManagerCallback* cb = childMM->GetCallback();
@@ -7692,17 +7693,17 @@ nsContentUtils::CallOnAllRemoteChildren(
 
 void
 nsContentUtils::CallOnAllRemoteChildren(nsPIDOMWindowOuter* aWindow,
                                         CallOnRemoteChildFunction aCallback,
                                         void* aArg)
 {
   nsGlobalWindowOuter* window = nsGlobalWindowOuter::Cast(aWindow);
   if (window->IsChromeWindow()) {
-    RefPtr<ChromeMessageBroadcaster> windowMM = window->GetMessageManager();
+    RefPtr<MessageBroadcaster> windowMM = window->GetMessageManager();
     if (windowMM) {
       CallOnAllRemoteChildren(windowMM, aCallback, aArg);
     }
   }
 }
 
 struct UIStateChangeInfo {
   UIStateChangeType mShowAccelerators;
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -119,27 +119,27 @@ template<class T> class nsReadingIterato
 
 namespace mozilla {
 class Dispatcher;
 class ErrorResult;
 class EventListenerManager;
 class HTMLEditor;
 
 namespace dom {
-class ChromeMessageBroadcaster;
 struct CustomElementDefinition;
 class DocumentFragment;
 class Element;
 class Event;
 class EventTarget;
 class HTMLInputElement;
 class IPCDataTransfer;
 class IPCDataTransferItem;
 struct LifecycleCallbackArgs;
 struct LifecycleAdoptedCallbackArgs;
+class MessageBroadcaster;
 class NodeInfo;
 class nsIContentChild;
 class nsIContentParent;
 class TabChild;
 class Selection;
 class TabParent;
 } // namespace dom
 
@@ -3300,17 +3300,17 @@ private:
   static mozilla::EventClassID
   GetEventClassIDFromMessage(mozilla::EventMessage aEventMessage);
 
   // Fills in aInfo with the tokens from the supplied autocomplete attribute.
   static AutocompleteAttrState InternalSerializeAutocompleteAttribute(const nsAttrValue* aAttrVal,
                                                                       mozilla::dom::AutocompleteInfo& aInfo,
                                                                       bool aGrantAllValidValue = false);
 
-  static bool CallOnAllRemoteChildren(mozilla::dom::ChromeMessageBroadcaster* aManager,
+  static bool CallOnAllRemoteChildren(mozilla::dom::MessageBroadcaster* aManager,
                                       CallOnRemoteChildFunction aCallback,
                                       void* aArg);
 
   /**
    * Gets the current cookie lifetime policy and cookie behavior for a given
    * principal by checking with preferences and the permission manager.
    *
    * Used in the implementation of InternalStorageAllowedForPrincipal.
--- a/dom/base/nsDOMMutationObserver.cpp
+++ b/dom/base/nsDOMMutationObserver.cpp
@@ -18,20 +18,17 @@
 #include "nsCSSPseudoElements.h"
 #include "nsError.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsServiceManagerUtils.h"
 #include "nsTextFragment.h"
 #include "nsThreadUtils.h"
 
 using namespace mozilla;
-
-using mozilla::dom::TreeOrderComparator;
-using mozilla::dom::Animation;
-using mozilla::dom::Element;
+using namespace mozilla::dom;
 
 AutoTArray<RefPtr<nsDOMMutationObserver>, 4>*
   nsDOMMutationObserver::sScheduledMutationObservers = nullptr;
 
 uint32_t nsDOMMutationObserver::sMutationLevel = 0;
 uint64_t nsDOMMutationObserver::sCount = 0;
 
 AutoTArray<AutoTArray<RefPtr<nsDOMMutationObserver>, 4>, 4>*
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -2942,17 +2942,17 @@ nsFrameLoader::EnsureMessageManager()
 
     if (!parentManager) {
       parentManager = window->GetMessageManager();
     }
   } else {
     parentManager = nsFrameMessageManager::GetGlobalMessageManager();
   }
 
-  mMessageManager = new ChromeMessageSender(nullptr, parentManager);
+  mMessageManager = new ChromeMessageSender(parentManager);
   if (!IsRemoteFrame()) {
     nsresult rv = MaybeCreateDocShell();
     if (NS_FAILED(rv)) {
       return rv;
     }
     NS_ASSERTION(mDocShell,
                  "MaybeCreateDocShell succeeded, but null mDocShell");
     if (!mDocShell) {
@@ -3383,17 +3383,17 @@ nsFrameLoader::PopulateUserContextIdFrom
       aAttr.mUserContextId = userContextIdStr.ToInteger(&rv);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   return NS_OK;
 }
 
-ChromeMessageSender*
+ProcessMessageManager*
 nsFrameLoader::GetProcessMessageManager() const
 {
   return mRemoteBrowser ? mRemoteBrowser->Manager()->GetMessageManager()
                         : nullptr;
 };
 
 JSObject*
 nsFrameLoader::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
--- a/dom/base/nsFrameLoader.h
+++ b/dom/base/nsFrameLoader.h
@@ -48,16 +48,17 @@ namespace mozilla {
 
 class OriginAttributes;
 
 namespace dom {
 class ChromeMessageSender;
 class ContentParent;
 class MessageSender;
 class PBrowserParent;
+class ProcessMessageManager;
 class Promise;
 class TabParent;
 class MutableTabContext;
 
 namespace ipc {
 class StructuredCloneData;
 } // namespace ipc
 
@@ -328,17 +329,17 @@ public:
    */
   void ApplySandboxFlags(uint32_t sandboxFlags);
 
   void GetURL(nsString& aURL, nsIPrincipal** aTriggeringPrincipal);
 
   // Properly retrieves documentSize of any subdocument type.
   nsresult GetWindowDimensions(nsIntRect& aRect);
 
-  virtual mozilla::dom::ChromeMessageSender* GetProcessMessageManager() const override;
+  virtual mozilla::dom::ProcessMessageManager* GetProcessMessageManager() const override;
 
   // public because a callback needs these.
   RefPtr<mozilla::dom::ChromeMessageSender> mMessageManager;
   RefPtr<nsInProcessTabChildGlobal> mChildMessageManager;
 
   virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
 
 private:
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -31,23 +31,24 @@
 #include "xpcpublic.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/CycleCollectedJSContext.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ScriptPreloader.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/dom/ChildProcessMessageManager.h"
 #include "mozilla/dom/ChromeMessageBroadcaster.h"
-#include "mozilla/dom/ChromeMessageSender.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/MessageManagerBinding.h"
 #include "mozilla/dom/MessagePort.h"
 #include "mozilla/dom/ContentParent.h"
+#include "mozilla/dom/ParentProcessMessageManager.h"
 #include "mozilla/dom/PermissionMessageUtils.h"
 #include "mozilla/dom/ProcessGlobal.h"
+#include "mozilla/dom/ProcessMessageManager.h"
 #include "mozilla/dom/ResolveSystemBinding.h"
 #include "mozilla/dom/SameProcessMessageQueue.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/ToJSValue.h"
 #include "mozilla/dom/ipc/StructuredCloneData.h"
 #include "mozilla/dom/DOMStringList.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 #include "nsPrintfCString.h"
@@ -157,17 +158,17 @@ NS_INTERFACE_MAP_END
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameMessageManager)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFrameMessageManager)
 
 void
 MessageManagerCallback::DoGetRemoteType(nsAString& aRemoteType,
                                         ErrorResult& aError) const
 {
   aRemoteType.Truncate();
-  mozilla::dom::ChromeMessageSender* parent = GetProcessMessageManager();
+  mozilla::dom::ProcessMessageManager* parent = GetProcessMessageManager();
   if (!parent) {
     return;
   }
 
   parent->GetRemoteType(aRemoteType, aError);
 }
 
 bool
@@ -911,36 +912,34 @@ nsFrameMessageManager::SetCallback(Messa
 }
 
 void
 nsFrameMessageManager::Close()
 {
   if (!mClosed) {
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
-      obs->NotifyObservers(NS_ISUPPORTS_CAST(nsIContentFrameMessageManager*, this),
-                            "message-manager-close", nullptr);
+      obs->NotifyObservers(this, "message-manager-close", nullptr);
     }
   }
   mClosed = true;
   mCallback = nullptr;
   mOwnedCallback = nullptr;
 }
 
 void
 nsFrameMessageManager::Disconnect(bool aRemoveFromParent)
 {
   // Notify message-manager-close if we haven't already.
   Close();
 
   if (!mDisconnected) {
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
-       obs->NotifyObservers(NS_ISUPPORTS_CAST(nsIContentFrameMessageManager*, this),
-                            "message-manager-disconnect", nullptr);
+       obs->NotifyObservers(this, "message-manager-disconnect", nullptr);
     }
   }
 
   ClearParentManager(aRemoveFromParent);
 
   mDisconnected = true;
   if (!mHandlingMessage) {
     mListeners.Clear();
@@ -995,20 +994,20 @@ nsFrameMessageManager::GetInitialProcess
 
   if (!JS_WrapValue(aCx, &init)) {
     aError.NoteJSContextException(aCx);
     return;
   }
   aInitialProcessData.set(init);
 }
 
-already_AddRefed<ChromeMessageSender>
+already_AddRefed<ProcessMessageManager>
 nsFrameMessageManager::GetProcessMessageManager(ErrorResult& aError)
 {
-  RefPtr<ChromeMessageSender> pmm;
+  RefPtr<ProcessMessageManager> pmm;
   if (mCallback) {
     pmm = mCallback->GetProcessMessageManager();
   }
   return pmm.forget();
 }
 
 void
 nsFrameMessageManager::GetRemoteType(nsAString& aRemoteType, ErrorResult& aError) const
@@ -1437,32 +1436,32 @@ nsMessageManagerScriptExecutor::MarkScop
   for (uint32_t i = 0; i < mAnonymousGlobalScopes.Length(); ++i) {
     mAnonymousGlobalScopes[i].exposeToActiveJS();
   }
 }
 
 NS_IMPL_ISUPPORTS(nsScriptCacheCleaner, nsIObserver)
 
 ChildProcessMessageManager* nsFrameMessageManager::sChildProcessManager = nullptr;
-ChromeMessageBroadcaster* nsFrameMessageManager::sParentProcessManager = nullptr;
+ParentProcessMessageManager* nsFrameMessageManager::sParentProcessManager = nullptr;
 nsFrameMessageManager* nsFrameMessageManager::sSameProcessParentManager = nullptr;
 
 class nsAsyncMessageToSameProcessChild : public nsSameProcessAsyncMessageBase,
                                          public Runnable
 {
 public:
   nsAsyncMessageToSameProcessChild(JS::RootingContext* aRootingCx,
                                    JS::Handle<JSObject*> aCpows)
     : nsSameProcessAsyncMessageBase(aRootingCx, aCpows)
     , mozilla::Runnable("nsAsyncMessageToSameProcessChild")
   { }
   NS_IMETHOD Run() override
   {
     nsFrameMessageManager* ppm = nsFrameMessageManager::GetChildProcessManager();
-    ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm), nullptr, ppm);
+    ReceiveMessage(ppm, nullptr, ppm);
     return NS_OK;
   }
 };
 
 
 /**
  * Send messages to an imaginary child process in a single-process scenario.
  */
@@ -1589,17 +1588,17 @@ class nsAsyncMessageToSameProcessParent 
 public:
   nsAsyncMessageToSameProcessParent(JS::RootingContext* aRootingCx,
                                     JS::Handle<JSObject*> aCpows)
     : nsSameProcessAsyncMessageBase(aRootingCx, aCpows)
   { }
   nsresult HandleMessage() override
   {
     nsFrameMessageManager* ppm = nsFrameMessageManager::sSameProcessParentManager;
-    ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm), nullptr, ppm);
+    ReceiveMessage(ppm, nullptr, ppm);
     return NS_OK;
   }
 };
 
 /**
  * Send messages to the imaginary parent process in a single-process scenario.
  */
 class SameChildProcessMessageManagerCallback : public MessageManagerCallback
@@ -1657,47 +1656,44 @@ public:
 
 
 // This creates the global parent process message manager.
 nsresult
 NS_NewParentProcessMessageManager(nsISupports** aResult)
 {
   NS_ASSERTION(!nsFrameMessageManager::sParentProcessManager,
                "Re-creating sParentProcessManager");
-  RefPtr<ChromeMessageBroadcaster> mm =
-    new ChromeMessageBroadcaster(MessageManagerFlags::MM_PROCESSMANAGER);
+  RefPtr<ParentProcessMessageManager> mm = new ParentProcessMessageManager();
   nsFrameMessageManager::sParentProcessManager = mm;
   nsFrameMessageManager::NewProcessMessageManager(false); // Create same process message manager.
   mm.forget(aResult);
   return NS_OK;
 }
 
 
-ChromeMessageSender*
+ProcessMessageManager*
 nsFrameMessageManager::NewProcessMessageManager(bool aIsRemote)
 {
   if (!nsFrameMessageManager::sParentProcessManager) {
      nsCOMPtr<nsISupports> dummy =
        do_GetService("@mozilla.org/parentprocessmessagemanager;1");
   }
 
   MOZ_ASSERT(nsFrameMessageManager::sParentProcessManager,
              "parent process manager not created");
-  ChromeMessageSender* mm;
+  ProcessMessageManager* mm;
   if (aIsRemote) {
     // Callback is set in ContentParent::InitInternal so that the process has
     // already started when we send pending scripts.
-    mm = new ChromeMessageSender(nullptr,
-                                 nsFrameMessageManager::sParentProcessManager,
-                                 MessageManagerFlags::MM_PROCESSMANAGER);
+    mm = new ProcessMessageManager(nullptr,
+                                   nsFrameMessageManager::sParentProcessManager);
   } else {
-    mm = new ChromeMessageSender(new SameParentProcessMessageManagerCallback(),
-                                 nsFrameMessageManager::sParentProcessManager,
-                                 MessageManagerFlags::MM_PROCESSMANAGER |
-                                 MessageManagerFlags::MM_OWNSCALLBACK);
+    mm = new ProcessMessageManager(new SameParentProcessMessageManagerCallback(),
+                                   nsFrameMessageManager::sParentProcessManager,
+                                   MessageManagerFlags::MM_OWNSCALLBACK);
     sSameProcessParentManager = mm;
   }
   return mm;
 }
 
 nsresult
 NS_NewChildProcessMessageManager(nsISupports** aResult)
 {
--- a/dom/base/nsFrameMessageManager.h
+++ b/dom/base/nsFrameMessageManager.h
@@ -38,22 +38,24 @@ class nsFrameLoader;
 
 namespace mozilla {
 namespace dom {
 
 class nsIContentParent;
 class nsIContentChild;
 class ChildProcessMessageManager;
 class ChromeMessageBroadcaster;
-class ChromeMessageSender;
 class ClonedMessageData;
+class MessageBroadcaster;
 class MessageListener;
 class MessageListenerManager;
 class MessageManagerReporter;
 template<typename T> class Optional;
+class ParentProcessMessageManager;
+class ProcessMessageManager;
 
 namespace ipc {
 
 // Note: we round the time we spend to the nearest millisecond. So a min value
 // of 1 ms actually captures from 500us and above.
 static const uint32_t kMinTelemetrySyncMessageManagerLatencyMs = 1;
 
 enum class MessageManagerFlags {
@@ -91,17 +93,17 @@ public:
                                       const nsAString& aMessage,
                                       StructuredCloneData& aData,
                                       JS::Handle<JSObject*> aCpows,
                                       nsIPrincipal* aPrincipal)
   {
     return NS_OK;
   }
 
-  virtual mozilla::dom::ChromeMessageSender* GetProcessMessageManager() const
+  virtual mozilla::dom::ProcessMessageManager* GetProcessMessageManager() const
   {
     return nullptr;
   }
 
   virtual void DoGetRemoteType(nsAString& aRemoteType,
                                ErrorResult& aError) const;
 
 protected:
@@ -197,17 +199,17 @@ public:
                         JS::Handle<JSObject*> aObjects,
                         nsIPrincipal* aPrincipal,
                         JS::Handle<JS::Value> aTransfers,
                         mozilla::ErrorResult& aError)
   {
     DispatchAsyncMessage(aCx, aMessageName, aObj, aObjects, aPrincipal, aTransfers,
                          aError);
   }
-  already_AddRefed<mozilla::dom::ChromeMessageSender>
+  already_AddRefed<mozilla::dom::ProcessMessageManager>
     GetProcessMessageManager(mozilla::ErrorResult& aError);
   void GetRemoteType(nsAString& aRemoteType, mozilla::ErrorResult& aError) const;
 
   // SyncMessageSender
   void SendSyncMessage(JSContext* aCx, const nsAString& aMessageName,
                        JS::Handle<JS::Value> aObj,
                        JS::Handle<JSObject*> aObjects,
                        nsIPrincipal* aPrincipal,
@@ -229,18 +231,17 @@ public:
   // GlobalProcessScriptLoader
   void GetInitialProcessData(JSContext* aCx,
                              JS::MutableHandle<JS::Value> aInitialProcessData,
                              mozilla::ErrorResult& aError);
 
   NS_DECL_NSIMESSAGESENDER
   NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
 
-  static mozilla::dom::ChromeMessageSender*
-  NewProcessMessageManager(bool aIsRemote);
+  static mozilla::dom::ProcessMessageManager* NewProcessMessageManager(bool aIsRemote);
 
   void ReceiveMessage(nsISupports* aTarget, nsFrameLoader* aTargetFrameLoader,
                       const nsAString& aMessage, bool aIsSync,
                       StructuredCloneData* aCloneData, mozilla::jsipc::CpowHolder* aCpows,
                       nsIPrincipal* aPrincipal, nsTArray<StructuredCloneData>* aRetVal,
                       mozilla::ErrorResult& aError)
   {
     ReceiveMessage(aTarget, aTargetFrameLoader, mClosed, aMessage, aIsSync, aCloneData,
@@ -264,17 +265,17 @@ public:
                                         nsIPrincipal* aPrincipal);
   bool IsGlobal() { return mGlobal; }
   bool IsBroadcaster() { return mIsBroadcaster; }
   bool IsChrome() { return mChrome; }
 
   // GetGlobalMessageManager creates the global message manager if it hasn't been yet.
   static already_AddRefed<mozilla::dom::ChromeMessageBroadcaster>
     GetGlobalMessageManager();
-  static mozilla::dom::ChromeMessageBroadcaster* GetParentProcessManager()
+  static mozilla::dom::ParentProcessMessageManager* GetParentProcessManager()
   {
     return sParentProcessManager;
   }
   static mozilla::dom::ChildProcessMessageManager* GetChildProcessManager()
   {
     return sChildProcessManager;
   }
   static void SetChildProcessManager(mozilla::dom::ChildProcessMessageManager* aManager)
@@ -284,17 +285,17 @@ public:
 
   void SetInitialProcessData(JS::HandleValue aInitialData);
 
   void LoadPendingScripts();
 
 protected:
   friend class MMListenerRemover;
 
-  virtual mozilla::dom::ChromeMessageBroadcaster* GetParentManager()
+  virtual mozilla::dom::MessageBroadcaster* GetParentManager()
   {
     return nullptr;
   }
   virtual void ClearParentManager(bool aRemove)
   {
   }
 
   void DispatchAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
@@ -338,17 +339,17 @@ protected:
   nsAutoPtr<mozilla::dom::ipc::MessageManagerCallback> mOwnedCallback;
   nsTArray<nsString> mPendingScripts;
   nsTArray<bool> mPendingScriptsGlobalStates;
   JS::Heap<JS::Value> mInitialProcessData;
 
   void LoadPendingScripts(nsFrameMessageManager* aManager,
                           nsFrameMessageManager* aChildMM);
 public:
-  static mozilla::dom::ChromeMessageBroadcaster* sParentProcessManager;
+  static mozilla::dom::ParentProcessMessageManager* sParentProcessManager;
   static nsFrameMessageManager* sSameProcessParentManager;
   static nsTArray<nsCOMPtr<nsIRunnable> >* sPendingSameProcessAsyncMessages;
 private:
   static mozilla::dom::ChildProcessMessageManager* sChildProcessManager;
 };
 
 /* A helper class for taking care of many details for async message sending
    within a single process.  Intended to be used like so:
--- a/dom/base/nsIdentifierMapEntry.h
+++ b/dom/base/nsIdentifierMapEntry.h
@@ -14,23 +14,30 @@
 #include "PLDHashTable.h"
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/net/ReferrerPolicy.h"
 
 #include "nsCOMPtr.h"
 #include "nsAtom.h"
+#include "nsHashKeys.h"
 #include "nsTArray.h"
 #include "nsTHashtable.h"
 
 class nsIContent;
 class nsContentList;
 class nsBaseContentList;
 
+namespace mozilla {
+namespace dom {
+class Element;
+}
+}
+
 /**
  * Right now our identifier map entries contain information for 'name'
  * and 'id' mappings of a given string. This is so that
  * nsHTMLDocument::ResolveName only has to do one hash lookup instead
  * of two. It's not clear whether this still matters for performance.
  *
  * We also store the document.all result list here. This is mainly so that
  * when all elements with the given ID are removed and we remove
--- a/dom/chrome-webidl/MessageManager.webidl
+++ b/dom/chrome-webidl/MessageManager.webidl
@@ -14,17 +14,17 @@ interface Principal;
  * These don't always correspond to process boundaries, but can.  For
  * each child-side message manager, there is always exactly one
  * corresponding parent-side message manager that it sends messages
  * to.  However, for each parent-side message manager, there may be
  * either one or many child-side managers it can message.
  *
  * Message managers that always have exactly one "other side" are of
  * type MessageSender.  Parent-side message managers that have many
- * "other sides" are of type ChromeMessageBroadcaster.
+ * "other sides" are of type MessageBroadcaster.
  *
  * Child-side message managers can send synchronous messages to their
  * parent side, but not the other way around.
  *
  * There are two realms of message manager hierarchies.  One realm
  * approximately corresponds to DOM elements, the other corresponds to
  * process boundaries.
  *
@@ -89,23 +89,23 @@ interface Principal;
  * can result in messages being dispatched across many OS processes,
  * and to many processes with different permissions.  Great care
  * should be taken when broadcasting.
  *
  * Interfaces
  * ----------
  *
  * The global MMg and window MMw's are message broadcasters implementing
- * ChromeMessageBroadcaster while the frame MMp's are simple message
- * senders (MessageSender). Their counterparts in the content processes
- * are message senders implementing ContentFrameMessageManager.
+ * MessageBroadcaster while the frame MMp's are simple message senders (MessageSender).
+ * Their counterparts in the content processes are message senders implementing
+ * ContentFrameMessageManager.
  *
  *                 MessageListenerManager
  *               /                        \
- * MessageSender                            ChromeMessageBroadcaster
+ * MessageSender                            MessageBroadcaster
  *       |
  * SyncMessageSender (content process/in-process only)
  *       |
  * ContentFrameMessageManager (content process/in-process only)
  *       |
  * nsIInProcessContentFrameMessageManager (in-process only)
  *
  *
@@ -347,16 +347,20 @@ interface SyncMessageSender : MessageSen
    */
   [Throws]
   sequence<any> sendRpcMessage(optional DOMString? messageName = null,
                                optional any obj,
                                optional object? objects = null,
                                optional Principal? principal = null);
 };
 
+/**
+ * ChildProcessMessageManager is used in a child process to communicate with the parent
+ * process.
+ */
 [ChromeOnly]
 interface ChildProcessMessageManager : SyncMessageSender
 {
 };
 
 [NoInterfaceObject]
 interface MessageManagerGlobal : SyncMessageSender
 {
@@ -498,17 +502,17 @@ ContentProcessMessageManager implements 
 
 /**
  * Message "broadcasters" don't have a single "other side" that they send messages to, but
  * rather a set of subordinate message managers. For example, broadcasting a message
  * through a window message manager will broadcast the message to all frame message
  * managers within its window.
  */
 [ChromeOnly]
-interface ChromeMessageBroadcaster : MessageListenerManager
+interface MessageBroadcaster : MessageListenerManager
 {
   /**
    * Like |sendAsyncMessage()|, but also broadcasts this message to
    * all "child" message managers of this message manager.  See long
    * comment above for details.
    *
    * WARNING: broadcasting messages can be very expensive and leak
    * sensitive data.  Use with extreme caution.
@@ -529,17 +533,43 @@ interface ChromeMessageBroadcaster : Mes
   MessageListenerManager getChildAt(unsigned long aIndex);
 
   /**
    * Some processes are kept alive after their last tab/window are closed for testing
    * (see dom.ipc.keepProcessesAlive). This function releases those.
    */
    void releaseCachedProcesses();
 };
-ChromeMessageBroadcaster implements GlobalProcessScriptLoader;
+
+/**
+ * ChromeMessageBroadcaster is used for window and group message managers.
+ */
+[ChromeOnly]
+interface ChromeMessageBroadcaster : MessageBroadcaster
+{
+};
 ChromeMessageBroadcaster implements FrameScriptLoader;
 
+/**
+ * ParentProcessMessageManager is used in a parent process to communicate with all the
+ * child processes.
+ */
+[ChromeOnly]
+interface ParentProcessMessageManager : MessageBroadcaster
+{
+};
+ParentProcessMessageManager implements GlobalProcessScriptLoader;
+
 [ChromeOnly]
 interface ChromeMessageSender : MessageSender
 {
 };
-ChromeMessageSender implements ProcessScriptLoader;
 ChromeMessageSender implements FrameScriptLoader;
+
+/**
+ * ProcessMessageManager is used in a parent process to communicate with a child process
+ * (or with the process itself in a single-process scenario).
+ */
+[ChromeOnly]
+interface ProcessMessageManager : MessageSender
+{
+};
+ProcessMessageManager implements ProcessScriptLoader;
--- a/dom/ipc/ContentBridgeParent.cpp
+++ b/dom/ipc/ContentBridgeParent.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/ContentBridgeParent.h"
-#include "mozilla/dom/ChromeMessageSender.h"
+#include "mozilla/dom/ProcessMessageManager.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 #include "nsXULAppAPI.h"
 #include "nsIObserverService.h"
 #include "base/task.h"
 
 using namespace mozilla::ipc;
 using namespace mozilla::jsipc;
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -152,17 +152,18 @@
 #include "nsIDocShellTreeOwner.h"
 #include "nsIXULWindow.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsIWindowWatcher.h"
 #include "nsPIWindowWatcher.h"
 #include "nsThread.h"
 #include "nsWindowWatcher.h"
 #include "nsIXULRuntime.h"
-#include "mozilla/dom/ChromeMessageBroadcaster.h"
+#include "mozilla/dom/ParentProcessMessageManager.h"
+#include "mozilla/dom/ProcessMessageManager.h"
 #include "mozilla/dom/nsMixedContentBlocker.h"
 #include "nsMemoryInfoDumper.h"
 #include "nsMemoryReporterManager.h"
 #include "nsScriptError.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStyleSheetService.h"
 #include "nsThreadUtils.h"
 #include "nsToolkitCompsCID.h"
@@ -529,17 +530,17 @@ ScriptableCPInfo::GetTabCount(int32_t* a
 NS_IMETHODIMP
 ScriptableCPInfo::GetMessageManager(nsISupports** aMessenger)
 {
   *aMessenger = nullptr;
   if (!mContentParent) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
-  RefPtr<ChromeMessageSender> manager = mContentParent->GetMessageManager();
+  RefPtr<ProcessMessageManager> manager = mContentParent->GetMessageManager();
   manager.forget(aMessenger);
   return NS_OK;
 }
 
 ProcessID
 GetTelemetryProcessID(const nsAString& remoteType)
 {
   // OOP WebExtensions run in a content process.
@@ -2234,17 +2235,17 @@ ContentParent::InitInternal(ProcessPrior
   MOZ_ASSERT(NS_SUCCEEDED(rv));
 
   // Let's copy the domain policy from the parent to the child (if it's active).
   StructuredCloneData initialData;
   nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
   if (ssm) {
     ssm->CloneDomainPolicy(&xpcomInit.domainPolicy());
 
-    if (ChromeMessageBroadcaster* mm = nsFrameMessageManager::sParentProcessManager) {
+    if (ParentProcessMessageManager* mm = nsFrameMessageManager::sParentProcessManager) {
       AutoJSAPI jsapi;
       if (NS_WARN_IF(!jsapi.Init(xpc::PrivilegedJunkScope()))) {
         MOZ_CRASH();
       }
       JS::RootedValue init(jsapi.cx());
       // We'll crash on failure, so use a IgnoredErrorResult (which also auto-suppresses
       // exceptions).
       IgnoredErrorResult rv;
--- a/dom/ipc/nsIContentParent.cpp
+++ b/dom/ipc/nsIContentParent.cpp
@@ -3,22 +3,22 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsIContentParent.h"
 
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/File.h"
-#include "mozilla/dom/ChromeMessageSender.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ContentBridgeParent.h"
 #include "mozilla/dom/ContentProcessManager.h"
 #include "mozilla/dom/PTabContext.h"
 #include "mozilla/dom/PermissionMessageUtils.h"
+#include "mozilla/dom/ProcessMessageManager.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/dom/ipc/IPCBlobInputStreamParent.h"
 #include "mozilla/dom/ipc/StructuredCloneData.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 #include "mozilla/ipc/FileDescriptorSetParent.h"
 #include "mozilla/ipc/PFileDescriptorSetParent.h"
 #include "mozilla/ipc/IPCStreamAlloc.h"
 #include "mozilla/ipc/IPCStreamDestination.h"
--- a/dom/ipc/nsIContentParent.h
+++ b/dom/ipc/nsIContentParent.h
@@ -39,17 +39,17 @@ class PParentToChildStreamParent;
 class PIPCBlobInputStreamParent;
 }
 
 namespace dom {
 
 class Blob;
 class BlobConstructorParams;
 class BlobImpl;
-class ChromeMessageSender;
+class ProcessMessageManager;
 class ContentParent;
 class ContentBridgeParent;
 class IPCTabContext;
 class PBrowserParent;
 
 class nsIContentParent : public nsISupports
                        , public mozilla::dom::ipc::MessageManagerCallback
                        , public CPOWManagerGetter
@@ -84,17 +84,17 @@ public:
   virtual bool IsContentParent() const { return false; }
 
   ContentParent* AsContentParent();
 
   virtual bool IsContentBridgeParent() const { return false; }
 
   ContentBridgeParent* AsContentBridgeParent();
 
-  mozilla::dom::ChromeMessageSender* GetMessageManager() const { return mMessageManager; }
+  mozilla::dom::ProcessMessageManager* GetMessageManager() const { return mMessageManager; }
 
   virtual bool SendActivate(PBrowserParent* aTab) = 0;
 
   virtual bool SendDeactivate(PBrowserParent* aTab) = 0;
 
   virtual int32_t Pid() const = 0;
 
   virtual mozilla::ipc::PParentToChildStreamParent*
@@ -157,17 +157,17 @@ protected: // IPDL methods
                                                  const IPC::Principal& aPrincipal,
                                                  nsTArray<ipc::StructuredCloneData>* aRetvals);
   virtual mozilla::ipc::IPCResult RecvAsyncMessage(const nsString& aMsg,
                                                    InfallibleTArray<jsipc::CpowEntry>&& aCpows,
                                                    const IPC::Principal& aPrincipal,
                                                    const ClonedMessageData& aData);
 
 protected: // members
-  RefPtr<mozilla::dom::ChromeMessageSender> mMessageManager;
+  RefPtr<mozilla::dom::ProcessMessageManager> mMessageManager;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentParent, NS_ICONTENTPARENT_IID)
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* mozilla_dom_nsIContentParent_h */
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -9,16 +9,17 @@
 #ifndef nsComputedDOMStyle_h__
 #define nsComputedDOMStyle_h__
 
 #include "mozilla/ArenaRefPtr.h"
 #include "mozilla/ArenaRefPtrInlines.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/StyleComplexColor.h"
 #include "mozilla/UniquePtr.h"
+#include "mozilla/dom/Element.h"
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include "nscore.h"
 #include "nsDOMCSSDeclaration.h"
 #include "mozilla/ComputedStyle.h"
 #include "nsIWeakReferenceUtils.h"
 #include "mozilla/gfx/Types.h"
 #include "nsCoord.h"