Bug 1533955 - Fire oop-browser-crashed event again if a subframe crashes. r=nika
authorMike Conley <mconley@mozilla.com>
Wed, 01 May 2019 20:04:50 +0000
changeset 530972 83eece97230e06f4b83940dc862a35e20c836532
parent 530971 918567a07dbb60dafc2b971afc4ce1610992d069
child 530973 52b38a9f7f8f663e5a3862bf88bcbd5711651d7e
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)
reviewersnika
bugs1533955
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
Bug 1533955 - Fire oop-browser-crashed event again if a subframe crashes. r=nika This also adds an isTopFrame attribute to the FrameCrashedEvent binding, which returns true if the frame that crashed was the top-most one. Differential Revision: https://phabricator.services.mozilla.com/D29236
dom/ipc/BrowserParent.cpp
dom/webidl/FrameCrashedEvent.webidl
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -480,21 +480,27 @@ void BrowserParent::ActorDestroy(ActorDe
     DestroyInternal();
     mIsDestroyed = true;
   }
 
   // Tell our embedder that the tab is now going away unless we're an
   // out-of-process iframe.
   RefPtr<nsFrameLoader> frameLoader = GetFrameLoader(true);
   nsCOMPtr<nsIObserverService> os = services::GetObserverService();
-  if (frameLoader && !mBrowserBridgeParent) {
+  if (frameLoader) {
     nsCOMPtr<Element> frameElement(mFrameElement);
     ReceiveMessage(CHILD_PROCESS_SHUTDOWN_MESSAGE, false, nullptr, nullptr,
                    nullptr);
-    frameLoader->DestroyComplete();
+
+    if (!mBrowsingContext->GetParent()) {
+      // If this is a top-level BrowsingContext, tell the frameloader it's time
+      // to go away. Otherwise, this is a subframe crash, and we can keep the
+      // frameloader around.
+      frameLoader->DestroyComplete();
+    }
 
     if (why == AbnormalShutdown && os) {
       os->NotifyObservers(ToSupports(frameLoader), "oop-frameloader-crashed",
                           nullptr);
       RefPtr<nsFrameLoaderOwner> owner = do_QueryObject(frameElement);
       if (owner) {
         RefPtr<nsFrameLoader> currentFrameLoader = owner->GetFrameLoader();
         // It's possible that the frameloader owner has already moved on
@@ -508,16 +514,17 @@ void BrowserParent::ActorDestroy(ActorDe
           } else {
             eventName = NS_LITERAL_STRING("oop-browser-crashed");
           }
 
           dom::FrameCrashedEventInit init;
           init.mBubbles = true;
           init.mCancelable = true;
           init.mBrowsingContextId = mBrowsingContext->Id();
+          init.mIsTopFrame = !mBrowsingContext->GetParent();
 
           RefPtr<dom::FrameCrashedEvent> event =
               dom::FrameCrashedEvent::Constructor(frameElement->OwnerDoc(),
                                                   eventName, init);
           event->SetTrusted(true);
           EventDispatcher::DispatchDOMEvent(frameElement, nullptr, event,
                                             nullptr, nullptr);
         }
--- a/dom/webidl/FrameCrashedEvent.webidl
+++ b/dom/webidl/FrameCrashedEvent.webidl
@@ -6,14 +6,20 @@
 
 [Constructor(DOMString type, optional FrameCrashedEventInit eventInitDict), ChromeOnly]
 interface FrameCrashedEvent : Event
 {
   /**
    * The browsingContextId of the frame that crashed.
    */
   readonly attribute unsigned long long browsingContextId;
+
+  /**
+   * True if the top-most frame crashed.
+   */
+  readonly attribute boolean isTopFrame;
 };
 
 dictionary FrameCrashedEventInit : EventInit
 {
   unsigned long long browsingContextId = 0;
+  boolean isTopFrame = false;
 };