Merge mozilla-central to autoland. CLOSED TREE
authorCsoregi Natalia <ncsoregi@mozilla.com>
Wed, 08 May 2019 00:48:33 +0300
changeset 531782 0119df88bee8139c1e4ddadb53ac3faaa6701fd2
parent 531781 036e5224f2a2087ae768aa208eeb00dfbd14f3c2 (current diff)
parent 531705 63bc837753d653ab13635e432400c1b6d31d12ca (diff)
child 531783 5c8c1f93843a8114a6576bee2989ee0558f52be4
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone68.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
Merge mozilla-central to autoland. CLOSED TREE
testing/mozharness/configs/unittests/linux_unittest.py
testing/mozharness/configs/unittests/mac_unittest.py
testing/mozharness/configs/unittests/win_unittest.py
--- a/dom/html/test/file_iframe_sandbox_e_if5.html
+++ b/dom/html/test/file_iframe_sandbox_e_if5.html
@@ -1,19 +1,30 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 341604</title>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script src="/tests/SimpleTest/EventUtils.js"></script>
-</head>
-<script type="application/javascript">
-function doTest() {
-  sendMouseEvent({type:'click'}, 'anchor');
-}
-</script>
-<body onload="doTest()">
-  I am sandboxed with 'allow-scripts and allow-top-navigation'
-
-  <a href="file_iframe_sandbox_top_navigation_pass.html" target='_top' id='anchor'>
-</body>
-</html>
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 341604</title>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script src="/tests/SimpleTest/EventUtils.js"></script>
+</head>
+<script type="application/javascript">
+function navigateAway() {
+  // Anchor clicks are only handled if we have a pres-context, and we may not
+  // have one yet by the time this runs, and getBoundingClientRect() /
+  // sendMouseEvent won't construct it after bug 1440537.
+  //
+  // So we may need to wait a few frames to make this reliable.
+  //
+  // FIXME(emilio, bug 1218456): This dance shouldn't be needed.
+  let anchor = document.getElementById("anchor");
+  if (anchor.getBoundingClientRect().width > 0)
+    anchor.click();
+  else
+    requestAnimationFrame(navigateAway);
+}
+</script>
+<body onload="navigateAway()">
+  I am sandboxed with 'allow-scripts and allow-top-navigation'
+
+  <a href="file_iframe_sandbox_top_navigation_pass.html" target='_top' id='anchor'>Click me</a>
+</body>
+</html>
--- a/dom/ipc/BrowserChild.h
+++ b/dom/ipc/BrowserChild.h
@@ -296,164 +296,163 @@ class BrowserChild final : public Browse
                                       StructuredCloneData& aData,
                                       JS::Handle<JSObject*> aCpows,
                                       nsIPrincipal* aPrincipal) override;
 
   virtual bool DoUpdateZoomConstraints(
       const uint32_t& aPresShellId, const ViewID& aViewId,
       const Maybe<ZoomConstraints>& aConstraints) override;
 
-  virtual mozilla::ipc::IPCResult RecvLoadURL(const nsCString& aURI,
-                                              const ShowInfo& aInfo) override;
+  mozilla::ipc::IPCResult RecvLoadURL(const nsCString& aURI,
+                                      const ShowInfo& aInfo);
 
-  virtual mozilla::ipc::IPCResult RecvResumeLoad(
-      const uint64_t& aPendingSwitchID, const ShowInfo& aInfo) override;
+  mozilla::ipc::IPCResult RecvResumeLoad(const uint64_t& aPendingSwitchID,
+                                         const ShowInfo& aInfo);
 
-  virtual mozilla::ipc::IPCResult RecvShow(
-      const ScreenIntSize& aSize, const ShowInfo& aInfo,
-      const bool& aParentIsActive, const nsSizeMode& aSizeMode) override;
+  mozilla::ipc::IPCResult RecvShow(const ScreenIntSize& aSize,
+                                   const ShowInfo& aInfo,
+                                   const bool& aParentIsActive,
+                                   const nsSizeMode& aSizeMode);
 
-  virtual mozilla::ipc::IPCResult RecvInitRendering(
+  mozilla::ipc::IPCResult RecvInitRendering(
       const TextureFactoryIdentifier& aTextureFactoryIdentifier,
       const layers::LayersId& aLayersId,
       const mozilla::layers::CompositorOptions& aCompositorOptions,
-      const bool& aLayersConnected) override;
+      const bool& aLayersConnected);
 
-  virtual mozilla::ipc::IPCResult RecvUpdateDimensions(
-      const mozilla::dom::DimensionInfo& aDimensionInfo) override;
-  virtual mozilla::ipc::IPCResult RecvSizeModeChanged(
-      const nsSizeMode& aSizeMode) override;
+  mozilla::ipc::IPCResult RecvUpdateDimensions(
+      const mozilla::dom::DimensionInfo& aDimensionInfo);
+  mozilla::ipc::IPCResult RecvSizeModeChanged(const nsSizeMode& aSizeMode);
 
-  virtual mozilla::ipc::IPCResult RecvChildToParentMatrix(
-      const mozilla::gfx::Matrix4x4& aMatrix) override;
+  mozilla::ipc::IPCResult RecvChildToParentMatrix(
+      const mozilla::gfx::Matrix4x4& aMatrix);
 
   mozilla::ipc::IPCResult RecvActivate();
 
   mozilla::ipc::IPCResult RecvDeactivate();
 
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
-  virtual mozilla::ipc::IPCResult RecvMouseEvent(
-      const nsString& aType, const float& aX, const float& aY,
-      const int32_t& aButton, const int32_t& aClickCount,
-      const int32_t& aModifiers, const bool& aIgnoreRootScrollFrame) override;
-
-  virtual mozilla::ipc::IPCResult RecvRealMouseMoveEvent(
-      const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId) override;
+  mozilla::ipc::IPCResult RecvMouseEvent(const nsString& aType, const float& aX,
+                                         const float& aY,
+                                         const int32_t& aButton,
+                                         const int32_t& aClickCount,
+                                         const int32_t& aModifiers,
+                                         const bool& aIgnoreRootScrollFrame);
 
-  virtual mozilla::ipc::IPCResult RecvNormalPriorityRealMouseMoveEvent(
+  mozilla::ipc::IPCResult RecvRealMouseMoveEvent(
       const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId) override;
+      const uint64_t& aInputBlockId);
 
-  virtual mozilla::ipc::IPCResult RecvSynthMouseMoveEvent(
+  mozilla::ipc::IPCResult RecvNormalPriorityRealMouseMoveEvent(
       const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId) override;
-  virtual mozilla::ipc::IPCResult RecvNormalPrioritySynthMouseMoveEvent(
-      const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId) override;
+      const uint64_t& aInputBlockId);
 
-  virtual mozilla::ipc::IPCResult RecvRealMouseButtonEvent(
-      const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId) override;
-  virtual mozilla::ipc::IPCResult RecvNormalPriorityRealMouseButtonEvent(
+  mozilla::ipc::IPCResult RecvSynthMouseMoveEvent(
       const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId) override;
-
-  virtual mozilla::ipc::IPCResult RecvRealDragEvent(
-      const WidgetDragEvent& aEvent, const uint32_t& aDragAction,
-      const uint32_t& aDropEffect, nsIPrincipal* aPrincipal) override;
+      const uint64_t& aInputBlockId);
+  mozilla::ipc::IPCResult RecvNormalPrioritySynthMouseMoveEvent(
+      const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
+      const uint64_t& aInputBlockId);
 
-  virtual mozilla::ipc::IPCResult RecvRealKeyEvent(
-      const mozilla::WidgetKeyboardEvent& aEvent) override;
-
-  virtual mozilla::ipc::IPCResult RecvNormalPriorityRealKeyEvent(
-      const mozilla::WidgetKeyboardEvent& aEvent) override;
+  mozilla::ipc::IPCResult RecvRealMouseButtonEvent(
+      const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
+      const uint64_t& aInputBlockId);
+  mozilla::ipc::IPCResult RecvNormalPriorityRealMouseButtonEvent(
+      const mozilla::WidgetMouseEvent& aEvent, const ScrollableLayerGuid& aGuid,
+      const uint64_t& aInputBlockId);
 
-  virtual mozilla::ipc::IPCResult RecvMouseWheelEvent(
-      const mozilla::WidgetWheelEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId) override;
+  mozilla::ipc::IPCResult RecvRealDragEvent(const WidgetDragEvent& aEvent,
+                                            const uint32_t& aDragAction,
+                                            const uint32_t& aDropEffect,
+                                            nsIPrincipal* aPrincipal);
 
-  virtual mozilla::ipc::IPCResult RecvNormalPriorityMouseWheelEvent(
+  mozilla::ipc::IPCResult RecvRealKeyEvent(
+      const mozilla::WidgetKeyboardEvent& aEvent);
+
+  mozilla::ipc::IPCResult RecvNormalPriorityRealKeyEvent(
+      const mozilla::WidgetKeyboardEvent& aEvent);
+
+  mozilla::ipc::IPCResult RecvMouseWheelEvent(
       const mozilla::WidgetWheelEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId) override;
+      const uint64_t& aInputBlockId);
+
+  mozilla::ipc::IPCResult RecvNormalPriorityMouseWheelEvent(
+      const mozilla::WidgetWheelEvent& aEvent, const ScrollableLayerGuid& aGuid,
+      const uint64_t& aInputBlockId);
 
-  virtual mozilla::ipc::IPCResult RecvRealTouchEvent(
-      const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId,
-      const nsEventStatus& aApzResponse) override;
+  mozilla::ipc::IPCResult RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
+                                             const ScrollableLayerGuid& aGuid,
+                                             const uint64_t& aInputBlockId,
+                                             const nsEventStatus& aApzResponse);
 
-  virtual mozilla::ipc::IPCResult RecvNormalPriorityRealTouchEvent(
+  mozilla::ipc::IPCResult RecvNormalPriorityRealTouchEvent(
       const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId,
-      const nsEventStatus& aApzResponse) override;
+      const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse);
 
-  virtual mozilla::ipc::IPCResult RecvRealTouchMoveEvent(
+  mozilla::ipc::IPCResult RecvRealTouchMoveEvent(
       const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId,
-      const nsEventStatus& aApzResponse) override;
+      const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse);
 
-  virtual mozilla::ipc::IPCResult RecvNormalPriorityRealTouchMoveEvent(
+  mozilla::ipc::IPCResult RecvNormalPriorityRealTouchMoveEvent(
       const WidgetTouchEvent& aEvent, const ScrollableLayerGuid& aGuid,
-      const uint64_t& aInputBlockId,
-      const nsEventStatus& aApzResponse) override;
+      const uint64_t& aInputBlockId, const nsEventStatus& aApzResponse);
 
-  virtual mozilla::ipc::IPCResult RecvNativeSynthesisResponse(
-      const uint64_t& aObserverId, const nsCString& aResponse) override;
+  mozilla::ipc::IPCResult RecvFlushTabState(const uint32_t& aFlushId);
 
-  virtual mozilla::ipc::IPCResult RecvFlushTabState(
-      const uint32_t& aFlushId) override;
+  mozilla::ipc::IPCResult RecvNativeSynthesisResponse(
+      const uint64_t& aObserverId, const nsCString& aResponse);
 
-  virtual mozilla::ipc::IPCResult RecvPluginEvent(
-      const WidgetPluginEvent& aEvent) override;
+  mozilla::ipc::IPCResult RecvPluginEvent(const WidgetPluginEvent& aEvent);
 
-  virtual mozilla::ipc::IPCResult RecvCompositionEvent(
-      const mozilla::WidgetCompositionEvent& aEvent) override;
+  mozilla::ipc::IPCResult RecvCompositionEvent(
+      const mozilla::WidgetCompositionEvent& aEvent);
 
-  virtual mozilla::ipc::IPCResult RecvNormalPriorityCompositionEvent(
-      const mozilla::WidgetCompositionEvent& aEvent) override;
+  mozilla::ipc::IPCResult RecvNormalPriorityCompositionEvent(
+      const mozilla::WidgetCompositionEvent& aEvent);
 
-  virtual mozilla::ipc::IPCResult RecvSelectionEvent(
-      const mozilla::WidgetSelectionEvent& aEvent) override;
+  mozilla::ipc::IPCResult RecvSelectionEvent(
+      const mozilla::WidgetSelectionEvent& aEvent);
 
-  virtual mozilla::ipc::IPCResult RecvNormalPrioritySelectionEvent(
-      const mozilla::WidgetSelectionEvent& aEvent) override;
+  mozilla::ipc::IPCResult RecvNormalPrioritySelectionEvent(
+      const mozilla::WidgetSelectionEvent& aEvent);
 
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
-  virtual mozilla::ipc::IPCResult RecvPasteTransferable(
+  mozilla::ipc::IPCResult RecvPasteTransferable(
       const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
-      nsIPrincipal* aRequestingPrincipal,
-      const uint32_t& aContentPolicyType) override;
+      nsIPrincipal* aRequestingPrincipal, const uint32_t& aContentPolicyType);
+
+  mozilla::ipc::IPCResult RecvActivateFrameEvent(const nsString& aType,
+                                                 const bool& aCapture);
 
-  virtual mozilla::ipc::IPCResult RecvActivateFrameEvent(
-      const nsString& aType, const bool& aCapture) override;
+  mozilla::ipc::IPCResult RecvLoadRemoteScript(const nsString& aURL,
+                                               const bool& aRunInGlobalScope);
 
-  virtual mozilla::ipc::IPCResult RecvLoadRemoteScript(
-      const nsString& aURL, const bool& aRunInGlobalScope) override;
+  mozilla::ipc::IPCResult RecvAsyncMessage(const nsString& aMessage,
+                                           InfallibleTArray<CpowEntry>&& aCpows,
+                                           nsIPrincipal* aPrincipal,
+                                           const ClonedMessageData& aData);
+  mozilla::ipc::IPCResult RecvSwappedWithOtherRemoteLoader(
+      const IPCTabContext& aContext);
 
-  virtual mozilla::ipc::IPCResult RecvAsyncMessage(
-      const nsString& aMessage, InfallibleTArray<CpowEntry>&& aCpows,
-      nsIPrincipal* aPrincipal, const ClonedMessageData& aData) override;
-  virtual mozilla::ipc::IPCResult RecvSwappedWithOtherRemoteLoader(
-      const IPCTabContext& aContext) override;
+  PDocAccessibleChild* AllocPDocAccessibleChild(PDocAccessibleChild*,
+                                                const uint64_t&,
+                                                const uint32_t&,
+                                                const IAccessibleHolder&);
 
-  virtual PDocAccessibleChild* AllocPDocAccessibleChild(
-      PDocAccessibleChild*, const uint64_t&, const uint32_t&,
-      const IAccessibleHolder&) override;
+  bool DeallocPDocAccessibleChild(PDocAccessibleChild*);
 
-  virtual bool DeallocPDocAccessibleChild(PDocAccessibleChild*) override;
+  PColorPickerChild* AllocPColorPickerChild(const nsString& aTitle,
+                                            const nsString& aInitialColor);
 
-  virtual PColorPickerChild* AllocPColorPickerChild(
-      const nsString& aTitle, const nsString& aInitialColor) override;
+  bool DeallocPColorPickerChild(PColorPickerChild* aActor);
 
-  virtual bool DeallocPColorPickerChild(PColorPickerChild* aActor) override;
+  PFilePickerChild* AllocPFilePickerChild(const nsString& aTitle,
+                                          const int16_t& aMode);
 
-  virtual PFilePickerChild* AllocPFilePickerChild(
-      const nsString& aTitle, const int16_t& aMode) override;
-
-  virtual bool DeallocPFilePickerChild(PFilePickerChild* aActor) override;
+  bool DeallocPFilePickerChild(PFilePickerChild* aActor);
 
   virtual nsIWebNavigation* WebNavigation() const override { return mWebNav; }
 
   virtual PuppetWidget* WebWidget() override { return mPuppetWidget; }
 
   bool IsTransparent() const { return mIsTransparent; }
 
   void GetMaxTouchPoints(uint32_t* aTouchPoints) {
@@ -526,55 +525,51 @@ class BrowserChild final : public Browse
   void ReinitRenderingForDeviceReset();
 
   static inline BrowserChild* GetFrom(nsIDOMWindow* aWindow) {
     nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
     nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
     return GetFrom(docShell);
   }
 
-  virtual mozilla::ipc::IPCResult RecvUIResolutionChanged(
-      const float& aDpi, const int32_t& aRounding,
-      const double& aScale) override;
+  mozilla::ipc::IPCResult RecvUIResolutionChanged(const float& aDpi,
+                                                  const int32_t& aRounding,
+                                                  const double& aScale);
 
-  virtual mozilla::ipc::IPCResult RecvThemeChanged(
-      nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache) override;
+  mozilla::ipc::IPCResult RecvThemeChanged(
+      nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache);
 
-  virtual mozilla::ipc::IPCResult RecvHandleAccessKey(
-      const WidgetKeyboardEvent& aEvent,
-      nsTArray<uint32_t>&& aCharCodes) override;
+  mozilla::ipc::IPCResult RecvHandleAccessKey(const WidgetKeyboardEvent& aEvent,
+                                              nsTArray<uint32_t>&& aCharCodes);
 
-  virtual mozilla::ipc::IPCResult RecvSetUseGlobalHistory(
-      const bool& aUse) override;
+  mozilla::ipc::IPCResult RecvSetUseGlobalHistory(const bool& aUse);
+
+  mozilla::ipc::IPCResult RecvHandledWindowedPluginKeyEvent(
+      const mozilla::NativeEventData& aKeyEventData, const bool& aIsConsumed);
 
-  virtual mozilla::ipc::IPCResult RecvHandledWindowedPluginKeyEvent(
-      const mozilla::NativeEventData& aKeyEventData,
-      const bool& aIsConsumed) override;
+  mozilla::ipc::IPCResult RecvPrint(const uint64_t& aOuterWindowID,
+                                    const PrintData& aPrintData);
 
-  virtual mozilla::ipc::IPCResult RecvPrint(
-      const uint64_t& aOuterWindowID, const PrintData& aPrintData) override;
-
-  virtual mozilla::ipc::IPCResult RecvUpdateNativeWindowHandle(
-      const uintptr_t& aNewHandle) override;
+  mozilla::ipc::IPCResult RecvUpdateNativeWindowHandle(
+      const uintptr_t& aNewHandle);
 
   /**
    * Native widget remoting protocol for use with windowed plugins with e10s.
    */
-  PPluginWidgetChild* AllocPPluginWidgetChild() override;
+  PPluginWidgetChild* AllocPPluginWidgetChild();
 
-  bool DeallocPPluginWidgetChild(PPluginWidgetChild* aActor) override;
+  bool DeallocPPluginWidgetChild(PPluginWidgetChild* aActor);
 
 #ifdef XP_WIN
   nsresult CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut);
 #endif
 
-  virtual PPaymentRequestChild* AllocPPaymentRequestChild() override;
+  PPaymentRequestChild* AllocPPaymentRequestChild();
 
-  virtual bool DeallocPPaymentRequestChild(
-      PPaymentRequestChild* aActor) override;
+  bool DeallocPPaymentRequestChild(PPaymentRequestChild* aActor);
 
   LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; }
   LayoutDeviceIntPoint GetChromeOffset() const { return mChromeOffset; };
 
   bool IPCOpen() const { return mIPCOpen; }
 
   bool ParentIsActive() const { return mParentIsActive; }
 
@@ -590,23 +585,23 @@ class BrowserChild final : public Browse
                                  bool aPreventDefault) const;
   void SetTargetAPZC(
       uint64_t aInputBlockId,
       const nsTArray<layers::SLGuidAndRenderRoot>& aTargets) const;
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
   mozilla::ipc::IPCResult RecvHandleTap(
       const layers::GeckoContentController::TapType& aType,
       const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
-      const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId) override;
+      const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId);
 
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
   mozilla::ipc::IPCResult RecvNormalPriorityHandleTap(
       const layers::GeckoContentController::TapType& aType,
       const LayoutDevicePoint& aPoint, const Modifiers& aModifiers,
-      const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId) override;
+      const ScrollableLayerGuid& aGuid, const uint64_t& aInputBlockId);
 
   void SetAllowedTouchBehavior(
       uint64_t aInputBlockId, const nsTArray<TouchBehaviorFlags>& aFlags) const;
 
   bool UpdateFrame(const layers::RepaintRequest& aRequest);
   bool NotifyAPZStateChange(
       const ViewID& aViewId,
       const layers::GeckoContentController::APZStateChange& aChange,
@@ -690,78 +685,72 @@ class BrowserChild final : public Browse
     return *sVisibleTabs;
   }
 
   bool UpdateSessionStore(uint32_t aFlushId);
 
  protected:
   virtual ~BrowserChild();
 
-  virtual PWindowGlobalChild* AllocPWindowGlobalChild(
-      const WindowGlobalInit& aInit) override;
+  PWindowGlobalChild* AllocPWindowGlobalChild(const WindowGlobalInit& aInit);
 
-  virtual bool DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) override;
+  bool DeallocPWindowGlobalChild(PWindowGlobalChild* aActor);
 
-  virtual PBrowserBridgeChild* AllocPBrowserBridgeChild(
+  PBrowserBridgeChild* AllocPBrowserBridgeChild(
       const nsString& aName, const nsString& aRemoteType,
-      BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags) override;
+      BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags);
 
-  virtual bool DeallocPBrowserBridgeChild(PBrowserBridgeChild* aActor) override;
+  bool DeallocPBrowserBridgeChild(PBrowserBridgeChild* aActor);
 
-  virtual mozilla::ipc::IPCResult RecvDestroy() override;
+  mozilla::ipc::IPCResult RecvDestroy();
 
-  virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(
-      const bool& aIsActive) override;
+  mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive);
 
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
-  virtual mozilla::ipc::IPCResult RecvRenderLayers(
+  mozilla::ipc::IPCResult RecvRenderLayers(
       const bool& aEnabled, const bool& aForce,
-      const layers::LayersObserverEpoch& aEpoch) override;
+      const layers::LayersObserverEpoch& aEpoch);
 
-  virtual mozilla::ipc::IPCResult RecvRequestRootPaint(
+  mozilla::ipc::IPCResult RecvRequestRootPaint(
       const IntRect& aRect, const float& aScale,
-      const nscolor& aBackgroundColor,
-      RequestRootPaintResolver&& aResolve) override;
+      const nscolor& aBackgroundColor, RequestRootPaintResolver&& aResolve);
 
-  virtual mozilla::ipc::IPCResult RecvRequestSubPaint(
+  mozilla::ipc::IPCResult RecvRequestSubPaint(
       const float& aScale, const nscolor& aBackgroundColor,
-      RequestSubPaintResolver&& aResolve) override;
+      RequestSubPaintResolver&& aResolve);
 
-  virtual mozilla::ipc::IPCResult RecvNavigateByKey(
-      const bool& aForward, const bool& aForDocumentNavigation) override;
+  mozilla::ipc::IPCResult RecvNavigateByKey(const bool& aForward,
+                                            const bool& aForDocumentNavigation);
 
-  virtual mozilla::ipc::IPCResult RecvRequestNotifyAfterRemotePaint() override;
+  mozilla::ipc::IPCResult RecvRequestNotifyAfterRemotePaint();
 
-  virtual mozilla::ipc::IPCResult RecvSuppressDisplayport(
-      const bool& aEnabled) override;
+  mozilla::ipc::IPCResult RecvSuppressDisplayport(const bool& aEnabled);
+
+  mozilla::ipc::IPCResult RecvParentActivated(const bool& aActivated);
 
-  virtual mozilla::ipc::IPCResult RecvParentActivated(
-      const bool& aActivated) override;
-
-  virtual mozilla::ipc::IPCResult RecvSetKeyboardIndicators(
+  mozilla::ipc::IPCResult RecvSetKeyboardIndicators(
       const UIStateChangeType& aShowAccelerators,
-      const UIStateChangeType& aShowFocusRings) override;
+      const UIStateChangeType& aShowFocusRings);
+
+  mozilla::ipc::IPCResult RecvStopIMEStateManagement();
 
-  virtual mozilla::ipc::IPCResult RecvStopIMEStateManagement() override;
+  mozilla::ipc::IPCResult RecvAwaitLargeAlloc();
 
-  virtual mozilla::ipc::IPCResult RecvAwaitLargeAlloc() override;
+  mozilla::ipc::IPCResult RecvSetWindowName(const nsString& aName);
 
-  virtual mozilla::ipc::IPCResult RecvSetWindowName(
-      const nsString& aName) override;
+  mozilla::ipc::IPCResult RecvAllowScriptsToClose();
 
-  virtual mozilla::ipc::IPCResult RecvAllowScriptsToClose() override;
+  mozilla::ipc::IPCResult RecvSetOriginAttributes(
+      const OriginAttributes& aOriginAttributes);
 
-  virtual mozilla::ipc::IPCResult RecvSetOriginAttributes(
-      const OriginAttributes& aOriginAttributes) override;
+  mozilla::ipc::IPCResult RecvSetWidgetNativeData(
+      const WindowsHandle& aWidgetNativeData);
 
-  virtual mozilla::ipc::IPCResult RecvSetWidgetNativeData(
-      const WindowsHandle& aWidgetNativeData) override;
-
-  virtual mozilla::ipc::IPCResult RecvGetContentBlockingLog(
-      GetContentBlockingLogResolver&& aResolve) override;
+  mozilla::ipc::IPCResult RecvGetContentBlockingLog(
+      GetContentBlockingLogResolver&& aResolve);
 
  private:
   void HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
                        const ScrollableLayerGuid& aGuid);
 
   // Notify others that our TabContext has been updated.
   //
   // You should call this after calling TabContext::SetTabContext().  We also
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -168,71 +168,139 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(BrowserP
 NS_IMPL_CYCLE_COLLECTING_RELEASE(BrowserParent)
 
 BrowserParent::BrowserParent(ContentParent* aManager, const TabId& aTabId,
                              const TabContext& aContext,
                              CanonicalBrowsingContext* aBrowsingContext,
                              uint32_t aChromeFlags,
                              BrowserBridgeParent* aBrowserBridgeParent)
     : TabContext(aContext),
+      mTabId(aTabId),
+      mManager(aManager),
+      mBrowsingContext(aBrowsingContext),
+      mLoadContext(nullptr),
       mFrameElement(nullptr),
+      mBrowserDOMWindow(nullptr),
+      mFrameLoader(nullptr),
+      mChromeFlags(aChromeFlags),
+      mBrowserBridgeParent(aBrowserBridgeParent),
       mContentCache(*this),
+      mRenderFrame{},
+      mLayerTreeEpoch{1},
+      mChildToParentConversionMatrix{},
       mRect(0, 0, 0, 0),
       mDimensions(0, 0),
       mOrientation(0),
       mDPI(0),
       mRounding(0),
       mDefaultScale(0),
       mUpdatedDimensions(false),
       mSizeMode(nsSizeMode_Normal),
-      mManager(aManager),
+      mClientOffset{},
+      mChromeOffset{},
+      mInitialDataTransferItems{},
+      mDnDVisualization{},
+      mDragValid(false),
+      mDragRect{},
+      mDragPrincipal{},
+      mCreatingWindow(false),
+      mDelayedURL{},
+      mDelayedFrameScripts{},
+      mCursor(eCursorInvalid),
+      mCustomCursor{},
+      mCustomCursorHotspotX(0),
+      mCustomCursorHotspotY(0),
+      mVerifyDropLinks{},
       mDocShellIsActive(false),
       mMarkedDestroying(false),
       mIsDestroyed(false),
-      mChromeFlags(aChromeFlags),
-      mDragValid(false),
-      mBrowsingContext(aBrowsingContext),
-      mBrowserBridgeParent(aBrowserBridgeParent),
-      mTabId(aTabId),
-      mCreatingWindow(false),
-      mCursor(eCursorInvalid),
-      mCustomCursorHotspotX(0),
-      mCustomCursorHotspotY(0),
       mTabSetsCursor(false),
-      mHasContentOpener(false)
-#ifdef DEBUG
-      ,
-      mActiveSupressDisplayportCount(0)
-#endif
-      ,
-      mLayerTreeEpoch{1},
+      mHasContentOpener(false),
       mPreserveLayers(false),
       mRenderLayers(true),
       mActiveInPriorityManager(false),
       mHasLayers(false),
       mHasPresented(false),
       mHasBeforeUnload(false),
+      mIsReadyToHandleInputEvents(false),
       mIsMouseEnterIntoWidgetEventSuppressed(false),
       mIsActiveRecordReplayTab(false) {
   MOZ_ASSERT(aManager);
   // When the input event queue is disabled, we don't need to handle the case
   // that some input events are dispatched before PBrowserConstructor.
   mIsReadyToHandleInputEvents = !ContentParent::IsInputEventQueueSupported();
 }
 
 BrowserParent::~BrowserParent() {}
 
+/* static */
+void BrowserParent::InitializeStatics() {
+  MOZ_ASSERT(XRE_IsParentProcess());
+  sFocusStack = new nsTArray<BrowserParent*>();
+  ClearOnShutdown(&sFocusStack);
+}
+
+/* static */
+BrowserParent* BrowserParent::GetFocused() {
+  if (!sFocusStack) {
+    return nullptr;
+  }
+  if (sFocusStack->IsEmpty()) {
+    return nullptr;
+  }
+  return sFocusStack->LastElement();
+}
+
+/*static*/
+BrowserParent* BrowserParent::GetFrom(nsFrameLoader* aFrameLoader) {
+  if (!aFrameLoader) {
+    return nullptr;
+  }
+  PBrowserParent* remoteBrowser = aFrameLoader->GetRemoteBrowser();
+  return static_cast<BrowserParent*>(remoteBrowser);
+}
+
+/*static*/
+BrowserParent* BrowserParent::GetFrom(nsIRemoteTab* aBrowserParent) {
+  return static_cast<BrowserParent*>(aBrowserParent);
+}
+
+/*static*/
+BrowserParent* BrowserParent::GetFrom(PBrowserParent* aBrowserParent) {
+  return static_cast<BrowserParent*>(aBrowserParent);
+}
+
+/*static*/
+BrowserParent* BrowserParent::GetFrom(nsIContent* aContent) {
+  RefPtr<nsFrameLoaderOwner> loaderOwner = do_QueryObject(aContent);
+  if (!loaderOwner) {
+    return nullptr;
+  }
+  RefPtr<nsFrameLoader> frameLoader = loaderOwner->GetFrameLoader();
+  return GetFrom(frameLoader);
+}
+
+/* static */
 BrowserParent* BrowserParent::GetBrowserParentFromLayersId(
     layers::LayersId aLayersId) {
   if (!sLayerToBrowserParentTable) {
     return nullptr;
   }
   return sLayerToBrowserParentTable->Get(uint64_t(aLayersId));
 }
 
+/*static*/
+TabId BrowserParent::GetTabIdFrom(nsIDocShell* docShell) {
+  nsCOMPtr<nsIBrowserChild> browserChild(BrowserChild::GetFrom(docShell));
+  if (browserChild) {
+    return static_cast<BrowserChild*>(browserChild.get())->GetTabId();
+  }
+  return TabId(0);
+}
+
 void BrowserParent::AddBrowserParentToTable(layers::LayersId aLayersId,
                                             BrowserParent* aBrowserParent) {
   if (!sLayerToBrowserParentTable) {
     sLayerToBrowserParentTable = new LayerToBrowserParentTable();
   }
   sLayerToBrowserParentTable->Put(uint64_t(aLayersId), aBrowserParent);
 }
 
@@ -242,18 +310,36 @@ void BrowserParent::RemoveBrowserParentF
   }
   sLayerToBrowserParentTable->Remove(uint64_t(aLayersId));
   if (sLayerToBrowserParentTable->Count() == 0) {
     delete sLayerToBrowserParentTable;
     sLayerToBrowserParentTable = nullptr;
   }
 }
 
-void BrowserParent::CacheFrameLoader(nsFrameLoader* aFrameLoader) {
-  mFrameLoader = aFrameLoader;
+already_AddRefed<nsILoadContext> BrowserParent::GetLoadContext() {
+  nsCOMPtr<nsILoadContext> loadContext;
+  if (mLoadContext) {
+    loadContext = mLoadContext;
+  } else {
+    bool isPrivate = mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
+    SetPrivateBrowsingAttributes(isPrivate);
+    bool useTrackingProtection = false;
+    nsCOMPtr<nsIDocShell> docShell = mFrameElement->OwnerDoc()->GetDocShell();
+    if (docShell) {
+      docShell->GetUseTrackingProtection(&useTrackingProtection);
+    }
+    loadContext = new LoadContext(
+        GetOwnerElement(), true /* aIsContent */, isPrivate,
+        mChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW,
+        mChromeFlags & nsIWebBrowserChrome::CHROME_FISSION_WINDOW,
+        useTrackingProtection, OriginAttributesRef());
+    mLoadContext = loadContext;
+  }
+  return loadContext.forget();
 }
 
 /**
  * Will return nullptr if there is no outer window available for the
  * document hosting the owner element of this BrowserParent. Also will return
  * nullptr if that outer window is in the process of closing.
  */
 already_AddRefed<nsPIDOMWindowOuter> BrowserParent::GetParentWindowOuter() {
@@ -265,16 +351,124 @@ already_AddRefed<nsPIDOMWindowOuter> Bro
   nsCOMPtr<nsPIDOMWindowOuter> parent = frame->OwnerDoc()->GetWindow();
   if (!parent || parent->Closed()) {
     return nullptr;
   }
 
   return parent.forget();
 }
 
+already_AddRefed<nsIWidget> BrowserParent::GetTopLevelWidget() {
+  nsCOMPtr<nsIContent> content = mFrameElement;
+  if (content) {
+    PresShell* presShell = content->OwnerDoc()->GetPresShell();
+    if (presShell) {
+      nsViewManager* vm = presShell->GetViewManager();
+      nsCOMPtr<nsIWidget> widget;
+      vm->GetRootWidget(getter_AddRefs(widget));
+      return widget.forget();
+    }
+  }
+  return nullptr;
+}
+
+already_AddRefed<nsIWidget> BrowserParent::GetWidget() const {
+  if (!mFrameElement) {
+    return nullptr;
+  }
+  nsCOMPtr<nsIWidget> widget = nsContentUtils::WidgetForContent(mFrameElement);
+  if (!widget) {
+    widget = nsContentUtils::WidgetForDocument(mFrameElement->OwnerDoc());
+  }
+  return widget.forget();
+}
+
+already_AddRefed<nsIWidget> BrowserParent::GetDocWidget() const {
+  if (!mFrameElement) {
+    return nullptr;
+  }
+  return do_AddRef(
+      nsContentUtils::WidgetForDocument(mFrameElement->OwnerDoc()));
+}
+
+nsIXULBrowserWindow* BrowserParent::GetXULBrowserWindow() {
+  if (!mFrameElement) {
+    return nullptr;
+  }
+
+  nsCOMPtr<nsIDocShell> docShell = mFrameElement->OwnerDoc()->GetDocShell();
+  if (!docShell) {
+    return nullptr;
+  }
+
+  nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
+  docShell->GetTreeOwner(getter_AddRefs(treeOwner));
+  if (!treeOwner) {
+    return nullptr;
+  }
+
+  nsCOMPtr<nsIXULWindow> window = do_GetInterface(treeOwner);
+  if (!window) {
+    return nullptr;
+  }
+
+  nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
+  window->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
+  return xulBrowserWindow;
+}
+
+a11y::DocAccessibleParent* BrowserParent::GetTopLevelDocAccessible() const {
+#ifdef ACCESSIBILITY
+  // XXX Consider managing non top level PDocAccessibles with their parent
+  // document accessible.
+  const ManagedContainer<PDocAccessibleParent>& docs =
+      ManagedPDocAccessibleParent();
+  for (auto iter = docs.ConstIter(); !iter.Done(); iter.Next()) {
+    auto doc = static_cast<a11y::DocAccessibleParent*>(iter.Get()->GetKey());
+    if (doc->IsTopLevel()) {
+      return doc;
+    }
+  }
+
+  MOZ_ASSERT(docs.Count() == 0,
+             "If there isn't a top level accessible doc "
+             "there shouldn't be an accessible doc at all!");
+#endif
+  return nullptr;
+}
+
+RenderFrame* BrowserParent::GetRenderFrame() {
+  if (!mRenderFrame.IsInitialized()) {
+    return nullptr;
+  }
+  return &mRenderFrame;
+}
+
+ShowInfo BrowserParent::GetShowInfo() {
+  TryCacheDPIAndScale();
+  if (mFrameElement) {
+    nsAutoString name;
+    mFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
+    bool allowFullscreen =
+        mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
+        mFrameElement->HasAttr(kNameSpaceID_None,
+                               nsGkAtoms::mozallowfullscreen);
+    bool isPrivate = mFrameElement->HasAttr(kNameSpaceID_None,
+                                            nsGkAtoms::mozprivatebrowsing);
+    bool isTransparent =
+        nsContentUtils::IsChromeDoc(mFrameElement->OwnerDoc()) &&
+        mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::transparent);
+    return ShowInfo(name, allowFullscreen, isPrivate, false, isTransparent,
+                    mDPI, mRounding, mDefaultScale.scale);
+  }
+
+  return ShowInfo(EmptyString(), false, false, false, false, mDPI, mRounding,
+                  mDefaultScale.scale);
+}
+
 void BrowserParent::SetOwnerElement(Element* aElement) {
   // If we held previous content then unregister for its events.
   RemoveWindowListeners();
 
   // If we change top-level documents then we need to change our
   // registration with them.
   RefPtr<nsPIWindowRoot> curTopLevelWin, newTopLevelWin;
   if (mFrameElement) {
@@ -356,16 +550,20 @@ void BrowserParent::SetOwnerElement(Elem
   }
 }
 
 NS_IMETHODIMP BrowserParent::GetOwnerElement(Element** aElement) {
   *aElement = do_AddRef(GetOwnerElement()).take();
   return NS_OK;
 }
 
+void BrowserParent::CacheFrameLoader(nsFrameLoader* aFrameLoader) {
+  mFrameLoader = aFrameLoader;
+}
+
 void BrowserParent::AddWindowListeners() {
   if (mFrameElement) {
     if (nsCOMPtr<nsPIDOMWindowOuter> window =
             mFrameElement->OwnerDoc()->GetWindow()) {
       nsCOMPtr<EventTarget> eventTarget = window->GetTopWindowRoot();
       if (eventTarget) {
         eventTarget->AddEventListener(NS_LITERAL_STRING("MozUpdateWindowPos"),
                                       this, false, false);
@@ -993,36 +1191,16 @@ mozilla::ipc::IPCResult BrowserParent::R
     doc->MaybeInitWindowEmulation();
     doc->SendParentCOMProxy();
 #  endif
   }
 #endif
   return IPC_OK();
 }
 
-a11y::DocAccessibleParent* BrowserParent::GetTopLevelDocAccessible() const {
-#ifdef ACCESSIBILITY
-  // XXX Consider managing non top level PDocAccessibles with their parent
-  // document accessible.
-  const ManagedContainer<PDocAccessibleParent>& docs =
-      ManagedPDocAccessibleParent();
-  for (auto iter = docs.ConstIter(); !iter.Done(); iter.Next()) {
-    auto doc = static_cast<a11y::DocAccessibleParent*>(iter.Get()->GetKey());
-    if (doc->IsTopLevel()) {
-      return doc;
-    }
-  }
-
-  MOZ_ASSERT(docs.Count() == 0,
-             "If there isn't a top level accessible doc "
-             "there shouldn't be an accessible doc at all!");
-#endif
-  return nullptr;
-}
-
 PFilePickerParent* BrowserParent::AllocPFilePickerParent(const nsString& aTitle,
                                                          const int16_t& aMode) {
   return new FilePickerParent(aTitle, aMode);
 }
 
 bool BrowserParent::DeallocPFilePickerParent(PFilePickerParent* actor) {
   delete actor;
   return true;
@@ -1756,42 +1934,16 @@ mozilla::ipc::IPCResult BrowserParent::R
   mCursor = aCursor;
   mCustomCursor = cursorImage;
   mCustomCursorHotspotX = aHotspotX;
   mCustomCursorHotspotY = aHotspotY;
 
   return IPC_OK();
 }
 
-nsIXULBrowserWindow* BrowserParent::GetXULBrowserWindow() {
-  if (!mFrameElement) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIDocShell> docShell = mFrameElement->OwnerDoc()->GetDocShell();
-  if (!docShell) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
-  docShell->GetTreeOwner(getter_AddRefs(treeOwner));
-  if (!treeOwner) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIXULWindow> window = do_GetInterface(treeOwner);
-  if (!window) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
-  window->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
-  return xulBrowserWindow;
-}
-
 mozilla::ipc::IPCResult BrowserParent::RecvSetStatus(const uint32_t& aType,
                                                      const nsString& aStatus) {
   nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow = GetXULBrowserWindow();
   if (!xulBrowserWindow) {
     return IPC_OK();
   }
 
   switch (aType) {
@@ -2494,34 +2646,16 @@ bool BrowserParent::SendPasteTransferabl
                                           const bool& aIsPrivateData,
                                           nsIPrincipal* aRequestingPrincipal,
                                           const uint32_t& aContentPolicyType) {
   return PBrowserParent::SendPasteTransferable(
       aDataTransfer, aIsPrivateData, aRequestingPrincipal, aContentPolicyType);
 }
 
 /* static */
-void BrowserParent::InitializeStatics() {
-  MOZ_ASSERT(XRE_IsParentProcess());
-  sFocusStack = new nsTArray<BrowserParent*>();
-  ClearOnShutdown(&sFocusStack);
-}
-
-/* static */
-BrowserParent* BrowserParent::GetFocused() {
-  if (!sFocusStack) {
-    return nullptr;
-  }
-  if (sFocusStack->IsEmpty()) {
-    return nullptr;
-  }
-  return sFocusStack->LastElement();
-}
-
-/* static */
 void BrowserParent::PushFocus(BrowserParent* aBrowserParent) {
   if (!sFocusStack) {
     MOZ_ASSERT_UNREACHABLE("PushFocus when not initialized");
     return;
   }
   if (!aBrowserParent->GetBrowserBridgeParent()) {
     // top-level Web content
     if (!sFocusStack->IsEmpty()) {
@@ -2592,65 +2726,16 @@ void BrowserParent::PopFocus(BrowserPare
   while (pos < sFocusStack->Length()) {
     BrowserParent* popped = sFocusStack->PopLastElement();
     BrowserParent* focused = GetFocused();
     LOGBROWSERFOCUS(("PopFocus changed focus to %p", focused));
     IMEStateManager::OnFocusMovedBetweenBrowsers(popped, focused);
   }
 }
 
-/*static*/
-BrowserParent* BrowserParent::GetFrom(nsFrameLoader* aFrameLoader) {
-  if (!aFrameLoader) {
-    return nullptr;
-  }
-  PBrowserParent* remoteBrowser = aFrameLoader->GetRemoteBrowser();
-  return static_cast<BrowserParent*>(remoteBrowser);
-}
-
-/*static*/
-BrowserParent* BrowserParent::GetFrom(nsIRemoteTab* aBrowserParent) {
-  return static_cast<BrowserParent*>(aBrowserParent);
-}
-
-/*static*/
-BrowserParent* BrowserParent::GetFrom(PBrowserParent* aBrowserParent) {
-  return static_cast<BrowserParent*>(aBrowserParent);
-}
-
-/*static*/
-BrowserParent* BrowserParent::GetFrom(nsIContent* aContent) {
-  RefPtr<nsFrameLoaderOwner> loaderOwner = do_QueryObject(aContent);
-  if (!loaderOwner) {
-    return nullptr;
-  }
-  RefPtr<nsFrameLoader> frameLoader = loaderOwner->GetFrameLoader();
-  return GetFrom(frameLoader);
-}
-
-/*static*/
-TabId BrowserParent::GetTabIdFrom(nsIDocShell* docShell) {
-  nsCOMPtr<nsIBrowserChild> browserChild(BrowserChild::GetFrom(docShell));
-  if (browserChild) {
-    return static_cast<BrowserChild*>(browserChild.get())->GetTabId();
-  }
-  return TabId(0);
-}
-
-RenderFrame* BrowserParent::GetRenderFrame() {
-  if (!mRenderFrame.IsInitialized()) {
-    return nullptr;
-  }
-  return &mRenderFrame;
-}
-
-BrowserBridgeParent* BrowserParent::GetBrowserBridgeParent() const {
-  return mBrowserBridgeParent;
-}
-
 mozilla::ipc::IPCResult BrowserParent::RecvRequestIMEToCommitComposition(
     const bool& aCancel, bool* aIsCommitted, nsString* aCommittedString) {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     *aIsCommitted = false;
     return IPC_OK();
   }
 
@@ -2727,30 +2812,16 @@ mozilla::ipc::IPCResult BrowserParent::R
 }
 
 mozilla::ipc::IPCResult BrowserParent::RecvSetInputContext(
     const InputContext& aContext, const InputContextAction& aAction) {
   IMEStateManager::SetInputContextForChildProcess(this, aContext, aAction);
   return IPC_OK();
 }
 
-already_AddRefed<nsIWidget> BrowserParent::GetTopLevelWidget() {
-  nsCOMPtr<nsIContent> content = mFrameElement;
-  if (content) {
-    PresShell* presShell = content->OwnerDoc()->GetPresShell();
-    if (presShell) {
-      nsViewManager* vm = presShell->GetViewManager();
-      nsCOMPtr<nsIWidget> widget;
-      vm->GetRootWidget(getter_AddRefs(widget));
-      return widget.forget();
-    }
-  }
-  return nullptr;
-}
-
 mozilla::ipc::IPCResult BrowserParent::RecvSetNativeChildOfShareableWindow(
     const uintptr_t& aChildWindow) {
 #if defined(XP_WIN)
   nsCOMPtr<nsIWidget> widget = GetTopLevelWidget();
   if (widget) {
     // Note that this call will probably cause a sync native message to the
     // process that owns the child window.
     widget->SetNativeData(NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW, aChildWindow);
@@ -2856,35 +2927,16 @@ void BrowserParent::TryCacheDPIAndScale(
 
   if (widget) {
     mDPI = widget->GetDPI();
     mRounding = widget->RoundsWidgetCoordinatesTo();
     mDefaultScale = widget->GetDefaultScale();
   }
 }
 
-already_AddRefed<nsIWidget> BrowserParent::GetWidget() const {
-  if (!mFrameElement) {
-    return nullptr;
-  }
-  nsCOMPtr<nsIWidget> widget = nsContentUtils::WidgetForContent(mFrameElement);
-  if (!widget) {
-    widget = nsContentUtils::WidgetForDocument(mFrameElement->OwnerDoc());
-  }
-  return widget.forget();
-}
-
-already_AddRefed<nsIWidget> BrowserParent::GetDocWidget() const {
-  if (!mFrameElement) {
-    return nullptr;
-  }
-  return do_AddRef(
-      nsContentUtils::WidgetForDocument(mFrameElement->OwnerDoc()));
-}
-
 void BrowserParent::ApzAwareEventRoutingToChild(
     ScrollableLayerGuid* aOutTargetGuid, uint64_t* aOutInputBlockId,
     nsEventStatus* aOutApzResponse) {
   // Let the widget know that the event will be sent to the child process,
   // which will (hopefully) send a confirmation notice back to APZ.
   // Do this even if APZ is off since we need it for swipe gesture support on
   // OS X without APZ.
   InputAPZContext::SetRoutedToChildProcess();
@@ -2953,38 +3005,16 @@ mozilla::ipc::IPCResult BrowserParent::R
 mozilla::ipc::IPCResult BrowserParent::RecvRespondStartSwipeEvent(
     const uint64_t& aInputBlockId, const bool& aStartSwipe) {
   if (nsCOMPtr<nsIWidget> widget = GetWidget()) {
     widget->ReportSwipeStarted(aInputBlockId, aStartSwipe);
   }
   return IPC_OK();
 }
 
-already_AddRefed<nsILoadContext> BrowserParent::GetLoadContext() {
-  nsCOMPtr<nsILoadContext> loadContext;
-  if (mLoadContext) {
-    loadContext = mLoadContext;
-  } else {
-    bool isPrivate = mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
-    SetPrivateBrowsingAttributes(isPrivate);
-    bool useTrackingProtection = false;
-    nsCOMPtr<nsIDocShell> docShell = mFrameElement->OwnerDoc()->GetDocShell();
-    if (docShell) {
-      docShell->GetUseTrackingProtection(&useTrackingProtection);
-    }
-    loadContext = new LoadContext(
-        GetOwnerElement(), true /* aIsContent */, isPrivate,
-        mChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW,
-        mChromeFlags & nsIWebBrowserChrome::CHROME_FISSION_WINDOW,
-        useTrackingProtection, OriginAttributesRef());
-    mLoadContext = loadContext;
-  }
-  return loadContext.forget();
-}
-
 // defined in nsIRemoteTab
 NS_IMETHODIMP
 BrowserParent::SetDocShellIsActive(bool isActive) {
   mDocShellIsActive = isActive;
   SetRenderLayers(isActive);
   Unused << SendSetDocShellIsActive(isActive);
 
   // update active accessible documents on windows
@@ -3699,38 +3729,16 @@ BrowserParent::StopApzAutoscroll(nsViewI
                                gfxUtils::GetContentRenderRoot());
 
       widget->StopAsyncAutoscroll(guid);
     }
   }
   return NS_OK;
 }
 
-ShowInfo BrowserParent::GetShowInfo() {
-  TryCacheDPIAndScale();
-  if (mFrameElement) {
-    nsAutoString name;
-    mFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
-    bool allowFullscreen =
-        mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
-        mFrameElement->HasAttr(kNameSpaceID_None,
-                               nsGkAtoms::mozallowfullscreen);
-    bool isPrivate = mFrameElement->HasAttr(kNameSpaceID_None,
-                                            nsGkAtoms::mozprivatebrowsing);
-    bool isTransparent =
-        nsContentUtils::IsChromeDoc(mFrameElement->OwnerDoc()) &&
-        mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::transparent);
-    return ShowInfo(name, allowFullscreen, isPrivate, false, isTransparent,
-                    mDPI, mRounding, mDefaultScale.scale);
-  }
-
-  return ShowInfo(EmptyString(), false, false, false, false, mDPI, mRounding,
-                  mDefaultScale.scale);
-}
-
 mozilla::ipc::IPCResult BrowserParent::RecvLookUpDictionary(
     const nsString& aText, nsTArray<FontRange>&& aFontRangeArray,
     const bool& aIsVertical, const LayoutDeviceIntPoint& aPoint) {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return IPC_OK();
   }
 
--- a/dom/ipc/BrowserParent.h
+++ b/dom/ipc/BrowserParent.h
@@ -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/. */
 
-#ifndef mozilla_tabs_BrowserParent_h
-#define mozilla_tabs_BrowserParent_h
+#ifndef mozilla_dom_BrowserParent_h
+#define mozilla_dom_BrowserParent_h
 
 #include "js/TypeDecls.h"
 #include "LiveResizeListener.h"
 #include "mozilla/ContentCache.h"
 #include "mozilla/dom/ipc/IdType.h"
 #include "mozilla/dom/PBrowserParent.h"
 #include "mozilla/dom/PContent.h"
 #include "mozilla/dom/PFilePickerParent.h"
@@ -111,42 +111,100 @@ class BrowserParent final : public PBrow
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(BrowserParent, nsIRemoteTab)
 
   BrowserParent(ContentParent* aManager, const TabId& aTabId,
                 const TabContext& aContext,
                 CanonicalBrowsingContext* aBrowsingContext,
                 uint32_t aChromeFlags,
                 BrowserBridgeParent* aBrowserBridgeParent = nullptr);
 
+  // Call from LayoutStatics only
+  static void InitializeStatics();
+
+  /**
+   * Returns the focused BrowserParent or nullptr if chrome or another app
+   * is focused.
+   */
+  static BrowserParent* GetFocused();
+
+  static BrowserParent* GetFrom(nsFrameLoader* aFrameLoader);
+
+  static BrowserParent* GetFrom(nsIRemoteTab* aBrowserParent);
+
+  static BrowserParent* GetFrom(PBrowserParent* aBrowserParent);
+
+  static BrowserParent* GetFrom(nsIContent* aContent);
+
+  static BrowserParent* GetBrowserParentFromLayersId(
+      layers::LayersId aLayersId);
+
+  static TabId GetTabIdFrom(nsIDocShell* docshell);
+
+  static bool AreRecordReplayTabsActive() {
+    return gNumActiveRecordReplayTabs != 0;
+  }
+
+  const TabId GetTabId() const { return mTabId; }
+
+  ContentParent* Manager() const { return mManager; }
+
+  CanonicalBrowsingContext* GetBrowsingContext() { return mBrowsingContext; }
+
+  already_AddRefed<nsILoadContext> GetLoadContext();
+
   Element* GetOwnerElement() const { return mFrameElement; }
+
+  nsIBrowserDOMWindow* GetBrowserDOMWindow() const { return mBrowserDOMWindow; }
+
+  // Returns the BrowserBridgeParent if this BrowserParent is for an
+  // out-of-process iframe and nullptr otherwise.
+  BrowserBridgeParent* GetBrowserBridgeParent() const {
+    return mBrowserBridgeParent;
+  }
+
   already_AddRefed<nsPIDOMWindowOuter> GetParentWindowOuter();
 
+  already_AddRefed<nsIWidget> GetTopLevelWidget();
+
+  // Returns the closest widget for our frameloader's content.
+  already_AddRefed<nsIWidget> GetWidget() const;
+
+  // Returns the top-level widget for our frameloader's document.
+  already_AddRefed<nsIWidget> GetDocWidget() const;
+
+  nsIXULBrowserWindow* GetXULBrowserWindow();
+
+  /**
+   * Return the top level doc accessible parent for this tab.
+   */
+  a11y::DocAccessibleParent* GetTopLevelDocAccessible() const;
+
+  layout::RenderFrame* GetRenderFrame();
+
+  ShowInfo GetShowInfo();
+
+  /**
+   * Let managees query if Destroy() is already called so they don't send out
+   * messages when the PBrowser actor is being destroyed.
+   */
+  bool IsDestroyed() const { return mIsDestroyed; }
+
   void SetOwnerElement(Element* aElement);
 
-  void CacheFrameLoader(nsFrameLoader* aFrameLoader);
-
-  nsIBrowserDOMWindow* GetBrowserDOMWindow() const { return mBrowserDOMWindow; }
-
   void SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserDOMWindow) {
     mBrowserDOMWindow = aBrowserDOMWindow;
   }
 
   void SetHasContentOpener(bool aHasContentOpener);
 
   void SwapFrameScriptsFrom(nsTArray<FrameScriptInfo>& aFrameScripts) {
     aFrameScripts.SwapElements(mDelayedFrameScripts);
   }
 
-  already_AddRefed<nsILoadContext> GetLoadContext();
-
-  already_AddRefed<nsIWidget> GetTopLevelWidget();
-
-  nsIXULBrowserWindow* GetXULBrowserWindow();
-
-  CanonicalBrowsingContext* GetBrowsingContext() { return mBrowsingContext; }
+  void CacheFrameLoader(nsFrameLoader* aFrameLoader);
 
   void Destroy();
 
   void RemoveWindowListeners();
 
   void AddWindowListeners();
 
   mozilla::ipc::IPCResult RecvMoveFocus(const bool& aForward,
@@ -334,21 +392,16 @@ class BrowserParent final : public PBrow
 
   bool DeallocPDocAccessibleParent(PDocAccessibleParent*);
 
   virtual mozilla::ipc::IPCResult RecvPDocAccessibleConstructor(
       PDocAccessibleParent* aDoc, PDocAccessibleParent* aParentDoc,
       const uint64_t& aParentID, const uint32_t& aMsaaID,
       const IAccessibleHolder& aDocCOMProxy) override;
 
-  /**
-   * Return the top level doc accessible parent for this tab.
-   */
-  a11y::DocAccessibleParent* GetTopLevelDocAccessible() const;
-
   PWindowGlobalParent* AllocPWindowGlobalParent(const WindowGlobalInit& aInit);
 
   bool DeallocPWindowGlobalParent(PWindowGlobalParent* aActor);
 
   virtual mozilla::ipc::IPCResult RecvPWindowGlobalConstructor(
       PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) override;
 
   PBrowserBridgeParent* AllocPBrowserBridgeParent(
@@ -491,51 +544,16 @@ class BrowserParent final : public PBrow
 
   bool HandleQueryContentEvent(mozilla::WidgetQueryContentEvent& aEvent);
 
   bool SendPasteTransferable(const IPCDataTransfer& aDataTransfer,
                              const bool& aIsPrivateData,
                              nsIPrincipal* aRequestingPrincipal,
                              const uint32_t& aContentPolicyType);
 
-  // Call from LayoutStatics only
-  static void InitializeStatics();
-
-  /**
-   * Returns the focused BrowserParent or nullptr if chrome or another app
-   * is focused.
-   */
-  static BrowserParent* GetFocused();
-
-  static BrowserParent* GetFrom(nsFrameLoader* aFrameLoader);
-
-  static BrowserParent* GetFrom(nsIRemoteTab* aBrowserParent);
-
-  static BrowserParent* GetFrom(PBrowserParent* aBrowserParent);
-
-  static BrowserParent* GetFrom(nsIContent* aContent);
-
-  static TabId GetTabIdFrom(nsIDocShell* docshell);
-
-  ContentParent* Manager() const { return mManager; }
-
-  /**
-   * Let managees query if Destroy() is already called so they don't send out
-   * messages when the PBrowser actor is being destroyed.
-   */
-  bool IsDestroyed() const { return mIsDestroyed; }
-
-  // Returns the closest widget for our frameloader's content.
-  already_AddRefed<nsIWidget> GetWidget() const;
-
-  // Returns the top-level widget for our frameloader's document.
-  already_AddRefed<nsIWidget> GetDocWidget() const;
-
-  const TabId GetTabId() const { return mTabId; }
-
   // Helper for transforming a point
   LayoutDeviceIntPoint TransformPoint(
       const LayoutDeviceIntPoint& aPoint,
       const LayoutDeviceToLayoutDeviceMatrix4x4& aMatrix);
   LayoutDevicePoint TransformPoint(
       const LayoutDevicePoint& aPoint,
       const LayoutDeviceToLayoutDeviceMatrix4x4& aMatrix);
 
@@ -603,57 +621,42 @@ class BrowserParent final : public PBrow
       nsIPrincipal* aPrincipal);
 
   void AddInitialDnDDataTo(DataTransfer* aDataTransfer,
                            nsIPrincipal** aPrincipal);
 
   bool TakeDragVisualization(RefPtr<mozilla::gfx::SourceSurface>& aSurface,
                              LayoutDeviceIntRect* aDragRect);
 
-  layout::RenderFrame* GetRenderFrame();
-
-  // Returns the BrowserBridgeParent if this BrowserParent is for an
-  // out-of-process iframe and nullptr otherwise.
-  BrowserBridgeParent* GetBrowserBridgeParent() const;
-
   mozilla::ipc::IPCResult RecvEnsureLayersConnected(
       CompositorOptions* aCompositorOptions);
 
   // LiveResizeListener implementation
   void LiveResizeStarted() override;
   void LiveResizeStopped() override;
 
   void SetReadyToHandleInputEvents() { mIsReadyToHandleInputEvents = true; }
   bool IsReadyToHandleInputEvents() { return mIsReadyToHandleInputEvents; }
 
-  static bool AreRecordReplayTabsActive() {
-    return gNumActiveRecordReplayTabs != 0;
-  }
-
   void NavigateByKey(bool aForward, bool aForDocumentNavigation);
 
-  ShowInfo GetShowInfo();
-
  protected:
   bool ReceiveMessage(
       const nsString& aMessage, bool aSync, ipc::StructuredCloneData* aData,
       mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
       nsTArray<ipc::StructuredCloneData>* aJSONRetVal = nullptr);
 
   mozilla::ipc::IPCResult RecvAsyncAuthPrompt(const nsCString& aUri,
                                               const nsString& aRealm,
                                               const uint64_t& aCallbackId);
 
   virtual mozilla::ipc::IPCResult Recv__delete__() override;
 
   virtual void ActorDestroy(ActorDestroyReason why) override;
 
-  nsCOMPtr<Element> mFrameElement;
-  nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
-
   mozilla::ipc::IPCResult RecvRemotePaintIsReady();
 
   mozilla::ipc::IPCResult RecvNotifyCompositorTransaction();
 
   mozilla::ipc::IPCResult RecvRemoteIsReadyToHandleInputEvents();
 
   mozilla::ipc::IPCResult RecvPaintWhileInterruptingJSNoOp(
       const LayersObserverEpoch& aEpoch);
@@ -672,93 +675,111 @@ class BrowserParent final : public PBrow
 
   mozilla::ipc::IPCResult RecvVisitURI(const URIParams& aURI,
                                        const Maybe<URIParams>& aLastVisitedURI,
                                        const uint32_t& aFlags);
 
   mozilla::ipc::IPCResult RecvQueryVisitedState(
       InfallibleTArray<URIParams>&& aURIs);
 
-  ContentCacheInParent mContentCache;
-
-  nsIntRect mRect;
-  ScreenIntSize mDimensions;
-  hal::ScreenOrientation mOrientation;
-  float mDPI;
-  int32_t mRounding;
-  CSSToLayoutDeviceScale mDefaultScale;
-  bool mUpdatedDimensions;
-  nsSizeMode mSizeMode;
-  LayoutDeviceIntPoint mClientOffset;
-  LayoutDeviceIntPoint mChromeOffset;
-
  private:
   void SuppressDisplayport(bool aEnabled);
 
   void DestroyInternal();
 
   void SetRenderLayersInternal(bool aEnabled, bool aForceRepaint);
 
   already_AddRefed<nsFrameLoader> GetFrameLoader(
       bool aUseCachedFrameLoaderAfterDestroy = false) const;
 
-  RefPtr<ContentParent> mManager;
   void TryCacheDPIAndScale();
 
   bool AsyncPanZoomEnabled() const;
 
-  // Cached value indicating the docshell active state of the remote browser.
-  bool mDocShellIsActive;
-
   // Update state prior to routing an APZ-aware event to the child process.
   // |aOutTargetGuid| will contain the identifier
   // of the APZC instance that handled the event. aOutTargetGuid may be null.
   // |aOutInputBlockId| will contain the identifier of the input block
   // that this event was added to, if there was one. aOutInputBlockId may be
   // null. |aOutApzResponse| will contain the response that the APZ gave when
   // processing the input block; this is used for generating appropriate
   // pointercancel events.
   void ApzAwareEventRoutingToChild(ScrollableLayerGuid* aOutTargetGuid,
                                    uint64_t* aOutInputBlockId,
                                    nsEventStatus* aOutApzResponse);
 
-  // When true, we've initiated normal shutdown and notified our managing
-  // PContent.
-  bool mMarkedDestroying;
-  // When true, the BrowserParent is invalid and we should not send IPC messages
-  // anymore.
-  bool mIsDestroyed;
+  // When dropping links we perform a roundtrip from
+  // Parent (SendRealDragEvent) -> Child -> Parent (RecvDropLinks)
+  // and have to ensure that the child did not modify links to be loaded.
+  bool QueryDropLinksForVerification();
+
+ private:
+  // This is used when APZ needs to find the BrowserParent associated with a
+  // layer to dispatch events.
+  typedef nsDataHashtable<nsUint64HashKey, BrowserParent*>
+      LayerToBrowserParentTable;
+  static LayerToBrowserParentTable* sLayerToBrowserParentTable;
+
+  static void AddBrowserParentToTable(layers::LayersId aLayersId,
+                                      BrowserParent* aBrowserParent);
+
+  static void RemoveBrowserParentFromTable(layers::LayersId aLayersId);
+
+  // Keeps track of which BrowserParent has keyboard focus
+  static StaticAutoPtr<nsTArray<BrowserParent*>> sFocusStack;
+
+  static void PushFocus(BrowserParent* aBrowserParent);
+
+  static void PopFocus(BrowserParent* aBrowserParent);
+
+  TabId mTabId;
 
+  RefPtr<ContentParent> mManager;
+  // The root browsing context loaded in this BrowserParent.
+  RefPtr<CanonicalBrowsingContext> mBrowsingContext;
+  nsCOMPtr<nsILoadContext> mLoadContext;
+  nsCOMPtr<Element> mFrameElement;
+  nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
+  // We keep a strong reference to the frameloader after we've sent the
+  // Destroy message and before we've received __delete__. This allows us to
+  // dispatch message manager messages during this time.
+  RefPtr<nsFrameLoader> mFrameLoader;
   uint32_t mChromeFlags;
 
+  // Pointer back to BrowserBridgeParent if there is one associated with
+  // this BrowserParent. This is non-owning to avoid cycles and is managed
+  // by the BrowserBridgeParent instance, which has the strong reference
+  // to this BrowserParent.
+  BrowserBridgeParent* mBrowserBridgeParent;
+
+  ContentCacheInParent mContentCache;
+
+  layout::RenderFrame mRenderFrame;
+  LayersObserverEpoch mLayerTreeEpoch;
+
+  Maybe<LayoutDeviceToLayoutDeviceMatrix4x4> mChildToParentConversionMatrix;
+
+  nsIntRect mRect;
+  ScreenIntSize mDimensions;
+  hal::ScreenOrientation mOrientation;
+  float mDPI;
+  int32_t mRounding;
+  CSSToLayoutDeviceScale mDefaultScale;
+  bool mUpdatedDimensions;
+  nsSizeMode mSizeMode;
+  LayoutDeviceIntPoint mClientOffset;
+  LayoutDeviceIntPoint mChromeOffset;
+
   nsTArray<nsTArray<IPCDataTransferItem>> mInitialDataTransferItems;
 
   RefPtr<gfx::DataSourceSurface> mDnDVisualization;
   bool mDragValid;
   LayoutDeviceIntRect mDragRect;
   nsCOMPtr<nsIPrincipal> mDragPrincipal;
 
-  nsCOMPtr<nsILoadContext> mLoadContext;
-
-  // We keep a strong reference to the frameloader after we've sent the
-  // Destroy message and before we've received __delete__. This allows us to
-  // dispatch message manager messages during this time.
-  RefPtr<nsFrameLoader> mFrameLoader;
-
-  // The root browsing context loaded in this BrowserParent.
-  RefPtr<CanonicalBrowsingContext> mBrowsingContext;
-
-  // Pointer back to BrowserBridgeParent if there is one associated with
-  // this BrowserParent. This is non-owning to avoid cycles and is managed
-  // by the BrowserBridgeParent instance, which has the strong reference
-  // to this BrowserParent.
-  BrowserBridgeParent* mBrowserBridgeParent;
-
-  TabId mTabId;
-
   // When loading a new tab or window via window.open, the child is
   // responsible for loading the URL it wants into the new BrowserChild. When
   // the parent receives the CreateWindow message, though, it sends a LoadURL
   // message, usually for about:blank. It's important for the about:blank load
   // to get processed because the Firefox frontend expects every new window to
   // immediately start loading something (see bug 1123090). However, we want
   // the child to process the LoadURL message before it returns from
   // ProvideWindow so that the URL sent from the parent doesn't override the
@@ -783,56 +804,37 @@ class BrowserParent final : public PBrow
   nsTArray<FrameScriptInfo> mDelayedFrameScripts;
 
   // Cached cursor setting from BrowserChild.  When the cursor is over the tab,
   // it should take this appearance.
   nsCursor mCursor;
   nsCOMPtr<imgIContainer> mCustomCursor;
   uint32_t mCustomCursorHotspotX, mCustomCursorHotspotY;
 
+  nsTArray<nsString> mVerifyDropLinks;
+
+#ifdef DEBUG
+  int32_t mActiveSupressDisplayportCount = 0;
+#endif
+
+  // Cached value indicating the docshell active state of the remote browser.
+  bool mDocShellIsActive;
+
+  // When true, we've initiated normal shutdown and notified our managing
+  // PContent.
+  bool mMarkedDestroying;
+  // When true, the BrowserParent is invalid and we should not send IPC messages
+  // anymore.
+  bool mIsDestroyed;
   // True if the cursor changes from the BrowserChild should change the widget
   // cursor.  This happens whenever the cursor is in the tab's region.
   bool mTabSetsCursor;
 
   bool mHasContentOpener;
 
-  // When dropping links we perform a roundtrip from
-  // Parent (SendRealDragEvent) -> Child -> Parent (RecvDropLinks)
-  // and have to ensure that the child did not modify links to be loaded.
-  bool QueryDropLinksForVerification();
-  nsTArray<nsString> mVerifyDropLinks;
-
-#ifdef DEBUG
-  int32_t mActiveSupressDisplayportCount;
-#endif
-
- private:
-  // This is used when APZ needs to find the BrowserParent associated with a
-  // layer to dispatch events.
-  typedef nsDataHashtable<nsUint64HashKey, BrowserParent*>
-      LayerToBrowserParentTable;
-  static LayerToBrowserParentTable* sLayerToBrowserParentTable;
-
-  static void AddBrowserParentToTable(layers::LayersId aLayersId,
-                                      BrowserParent* aBrowserParent);
-
-  static void RemoveBrowserParentFromTable(layers::LayersId aLayersId);
-
-  // Keeps track of which BrowserParent has keyboard focus
-  static StaticAutoPtr<nsTArray<BrowserParent*>> sFocusStack;
-
-  static void PushFocus(BrowserParent* aBrowserParent);
-
-  static void PopFocus(BrowserParent* aBrowserParent);
-
-  layout::RenderFrame mRenderFrame;
-  LayersObserverEpoch mLayerTreeEpoch;
-
-  Maybe<LayoutDeviceToLayoutDeviceMatrix4x4> mChildToParentConversionMatrix;
-
   // If this flag is set, then the tab's layers will be preserved even when
   // the tab's docshell is inactive.
   bool mPreserveLayers;
 
   // Holds the most recent value passed to the RenderLayers function. This
   // does not necessarily mean that the layers have finished rendering
   // and have uploaded - for that, use mHasLayers.
   bool mRenderLayers;
@@ -863,20 +865,16 @@ class BrowserParent final : public PBrow
   // How many record/replay tabs have active docshells in this process.
   static size_t gNumActiveRecordReplayTabs;
 
   // Whether this tab is contributing to gNumActiveRecordReplayTabs.
   bool mIsActiveRecordReplayTab;
 
   // Update whether this is an active record/replay tab.
   void SetIsActiveRecordReplayTab(bool aIsActive);
-
- public:
-  static BrowserParent* GetBrowserParentFromLayersId(
-      layers::LayersId aLayersId);
 };
 
 struct MOZ_STACK_CLASS BrowserParent::AutoUseNewTab final {
  public:
   AutoUseNewTab(BrowserParent* aNewTab, nsCString* aURLToLoad)
       : mNewTab(aNewTab), mURLToLoad(aURLToLoad) {
     MOZ_ASSERT(!aNewTab->mCreatingWindow);
 
@@ -892,9 +890,9 @@ struct MOZ_STACK_CLASS BrowserParent::Au
  private:
   BrowserParent* mNewTab;
   nsCString* mURLToLoad;
 };
 
 }  // namespace dom
 }  // namespace mozilla
 
-#endif  // mozilla_tabs_BrowserParent_h
+#endif  // mozilla_dom_BrowserParent_h
--- a/ipc/ipdl/ipdl/direct_call.py
+++ b/ipc/ipdl/ipdl/direct_call.py
@@ -12,18 +12,16 @@ DIRECT_CALL_OVERRIDES = {
     ("PAPZ", "parent"): (
         "RemoteContentController", "mozilla/layers/RemoteContentController.h"
     ),
 
     ("PBackgroundMutableFile", "parent"): (
         "BackgroundMutableFileParentBase", "mozilla/dom/filehandle/ActorsParent.h"
     ),
 
-    ("PBrowser", "parent"): ("BrowserParent", "mozilla/dom/BrowserParent.h"),
-
     ("PChromiumCDM", "parent"): ("ChromiumCDMParent", "ChromiumCDMParent.h"),
 
     ("PCompositorBridge", "parent"): (
         "CompositorBridgeParentBase", "mozilla/layers/CompositorBridgeParent.h"
     ),
 
     ("PContentPermissionRequest", "child"): (
         "RemotePermissionRequest", "nsContentPermissionHelper.h"
@@ -569,20 +567,16 @@ VIRTUAL_CALL_CLASSES = set([
     ("PExternalHelperApp", "parent"),
     ("PFTPChannel", "child"),
     ("PFTPChannel", "parent"),
     ("PHttpChannel", "child"),
     ("PHttpChannel", "parent"),
     ("PSessionStorageObserver", "child"),
     ("PSessionStorageObserver", "parent"),
 
-    # Recv* methods are MOZ_CAN_RUN_SCRIPT and OnMessageReceived is not, so
-    # it's not allowed to call them.
-    ("PBrowser", "child"),
-
     # can't be included safely for compilation error reasons
     ("PGMPContent", "parent"),
     ("PGMPService", "child"),
     ("PGMPService", "parent"),
     ("PGMPStorage", "parent"),
     ("PGMPVideoDecoder", "parent"),
     ("PGMPVideoEncoder", "parent"),
     ("PWebRenderBridge", "parent"),
--- a/js/src/proxy/Proxy.cpp
+++ b/js/src/proxy/Proxy.cpp
@@ -770,17 +770,17 @@ const Class js::ProxyClass =
 
 JS_FRIEND_API JSObject* js::NewProxyObject(JSContext* cx,
                                            const BaseProxyHandler* handler,
                                            HandleValue priv, JSObject* proto_,
                                            const ProxyOptions& options) {
   AssertHeapIsIdle();
   CHECK_THREAD(cx);
   if (proto_ != TaggedProto::LazyProto) {
-    cx->check(proto_); // |priv| might be cross-compartment.
+    cx->check(proto_);  // |priv| might be cross-compartment.
   }
 
   if (options.lazyProto()) {
     MOZ_ASSERT(!proto_);
     proto_ = TaggedProto::LazyProto;
   }
 
   return ProxyObject::New(cx, handler, priv, TaggedProto(proto_), options);
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -396,33 +396,38 @@ class MachCommands(MachCommandBase):
         tests = params['test_files']
         if len(tests) == 0:
             tests = [os.path.join(self.distdir, 'cppunittests')]
             manifest_path = os.path.join(
                 self.topsrcdir, 'testing', 'cppunittest.ini')
         else:
             manifest_path = None
 
+        utility_path = self.bindir
+
         if conditions.is_android(self):
             from mozrunner.devices.android_device import verify_android_device
             verify_android_device(self, install=False)
             return self.run_android_test(tests, symbols_path, manifest_path, log)
 
-        return self.run_desktop_test(tests, symbols_path, manifest_path, log)
+        return self.run_desktop_test(tests, symbols_path, manifest_path,
+                                     utility_path, log)
 
-    def run_desktop_test(self, tests, symbols_path, manifest_path, log):
+    def run_desktop_test(self, tests, symbols_path, manifest_path,
+                         utility_path, log):
         import runcppunittests as cppunittests
         from mozlog import commandline
 
         parser = cppunittests.CPPUnittestOptions()
         commandline.add_logging_group(parser)
         options, args = parser.parse_args()
 
         options.symbols_path = symbols_path
         options.manifest_path = manifest_path
+        options.utility_path = utility_path
         options.xre_path = self.bindir
 
         try:
             result = cppunittests.run_test_harness(options, tests)
         except Exception as e:
             log.error("Caught exception running cpp unit tests: %s" % str(e))
             result = False
             raise
--- a/testing/mozharness/configs/unittests/linux_unittest.py
+++ b/testing/mozharness/configs/unittests/linux_unittest.py
@@ -59,16 +59,17 @@ config = {
         "tools/*",
         "mozpack/*",
         "mozbuild/*",
     ],
     "suite_definitions": {
         "cppunittest": {
             "options": [
                 "--symbols-path=%(symbols_path)s",
+                "--utility-path=tests/bin",
                 "--xre-path=%(abs_app_dir)s"
             ],
             "run_filename": "runcppunittests.py",
             "testsdir": "cppunittest"
         },
         "jittest": {
             "options": [
                 "tests/bin/js",
--- a/testing/mozharness/configs/unittests/mac_unittest.py
+++ b/testing/mozharness/configs/unittests/mac_unittest.py
@@ -31,16 +31,17 @@ config = {
         "modules/*",
         "mozbase/*",
         "tools/*",
     ],
     "suite_definitions": {
         "cppunittest": {
             "options": [
                 "--symbols-path=%(symbols_path)s",
+                "--utility-path=tests/bin",
                 "--xre-path=%(abs_res_dir)s"
             ],
             "run_filename": "runcppunittests.py",
             "testsdir": "cppunittest"
         },
         "jittest": {
             "options": [
                 "tests/bin/js",
--- a/testing/mozharness/configs/unittests/win_unittest.py
+++ b/testing/mozharness/configs/unittests/win_unittest.py
@@ -54,16 +54,17 @@ config = {
         "tools/*",
         "mozpack/*",
         "mozbuild/*",
     ],
     "suite_definitions": {
         "cppunittest": {
             "options": [
                 "--symbols-path=%(symbols_path)s",
+                "--utility-path=tests/bin",
                 "--xre-path=%(abs_app_dir)s"
             ],
             "run_filename": "runcppunittests.py",
             "testsdir": "cppunittest"
         },
         "jittest": {
             "options": [
                 "tests/bin/js",
--- a/testing/runcppunittests.py
+++ b/testing/runcppunittests.py
@@ -10,16 +10,17 @@ import os
 from optparse import OptionParser
 from os import environ as env
 import manifestparser
 import mozprocess
 import mozinfo
 import mozcrash
 import mozfile
 import mozlog
+import mozrunner.utils
 
 SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
 
 # Export directory js/src for tests that need it.
 env['CPP_UNIT_TESTS_DIR_JS_SRC'] = os.path.abspath(os.path.join(SCRIPT_DIR, "..", ".."))
 
 
 class CPPUnitTests(object):
@@ -59,17 +60,22 @@ class CPPUnitTests(object):
                                                  processOutputLine=lambda _: None)
             # TODO: After bug 811320 is fixed, don't let .run() kill the process,
             # instead use a timeout in .wait() and then kill to get a stack.
             test_timeout = CPPUnitTests.TEST_PROC_TIMEOUT * timeout_factor
             proc.run(timeout=test_timeout,
                      outputTimeout=CPPUnitTests.TEST_PROC_NO_OUTPUT_TIMEOUT)
             proc.wait()
             if proc.output:
-                output = "\n%s" % "\n".join(proc.output)
+                if self.fix_stack:
+                    procOutput = [self.fix_stack(l) for l in proc.output]
+                else:
+                    procOutput = proc.output
+
+                output = "\n%s" % "\n".join(procOutput)
                 self.log.process_output(proc.pid, output, command=[prog])
             if proc.timedOut:
                 message = "timed out after %d seconds" % CPPUnitTests.TEST_PROC_TIMEOUT
                 self.log.test_end(basename, status='TIMEOUT', expected='PASS',
                                   message=message)
                 return False
             if mozcrash.check_for_crashes(tempdir, symbols_path,
                                           test_name=basename):
@@ -138,31 +144,37 @@ class CPPUnitTests(object):
 
             # media/mtransport tests statically link in NSS, which
             # causes ODR violations. See bug 1215679.
             assert 'ASAN_OPTIONS' not in env
             env['ASAN_OPTIONS'] = 'detect_leaks=0:detect_odr_violation=0'
 
         return env
 
-    def run_tests(self, programs, xre_path, symbols_path=None, interactive=False):
+    def run_tests(self, programs, xre_path, symbols_path=None,
+                  utility_path=None, interactive=False):
         """
         Run a set of C++ unit test programs.
 
         Arguments:
         * programs: An iterable containing (test path, test timeout factor) tuples
         * xre_path: A path to a directory containing a XUL Runtime Environment.
         * symbols_path: A path to a directory containing Breakpad-formatted
                         symbol files for producing stack traces on crash.
+        * utility_path: A path to a directory containing utility programs
+                        (xpcshell et al)
 
         Returns True if all test programs exited with a zero status, False
         otherwise.
         """
         self.xre_path = xre_path
         self.log = mozlog.get_default_logger()
+        if utility_path:
+            self.fix_stack = mozrunner.utils.get_stack_fixer_function(
+                utility_path, symbols_path)
         self.log.suite_start(programs, name='cppunittest')
         env = self.build_environment()
         pass_count = 0
         fail_count = 0
         for prog in programs:
             test_path = prog[0]
             timeout_factor = prog[1]
             single_result = self.run_one_test(test_path, env, symbols_path,
@@ -191,16 +203,20 @@ class CPPUnittestOptions(OptionParser):
                         action="store", type="string", dest="symbols_path",
                         default=None,
                         help="absolute path to directory containing breakpad symbols, or "
                         "the URL of a zip file containing symbols")
         self.add_option("--manifest-path",
                         action="store", type="string", dest="manifest_path",
                         default=None,
                         help="path to test manifest, if different from the path to test binaries")
+        self.add_option("--utility-path",
+                        action="store", type="string", dest="utility_path",
+                        default=None,
+                        help="path to directory containing utility programs")
 
 
 def extract_unittests_from_args(args, environ, manifest_path):
     """Extract unittests from args, expanding directories as needed"""
     mp = manifestparser.TestManifest(strict=True)
     tests = []
     binary_path = None
 
@@ -252,18 +268,20 @@ def update_mozinfo():
         path = os.path.split(path)[0]
     mozinfo.find_and_update_from_json(*dirs)
 
 
 def run_test_harness(options, args):
     update_mozinfo()
     progs = extract_unittests_from_args(args, mozinfo.info, options.manifest_path)
     options.xre_path = os.path.abspath(options.xre_path)
+    options.utility_path = os.path.abspath(options.utility_path)
     tester = CPPUnitTests()
-    result = tester.run_tests(progs, options.xre_path, options.symbols_path)
+    result = tester.run_tests(progs, options.xre_path, options.symbols_path,
+                              options.utility_path)
 
     return result
 
 
 def main():
     parser = CPPUnittestOptions()
     mozlog.commandline.add_logging_group(parser)
     options, args = parser.parse_args()