Bug 932309 - Don't null out mDoc in nsGlobalWindow::FreeInnerObjects, additional fixes. r=smaug.
authorPeter Van der Beken <peterv@propagandism.org>
Fri, 01 Nov 2013 14:31:00 +0100
changeset 153607 d4fdcf5f3c04afaef636a1777cf0bc35a6c2e0f9
parent 153606 e30f630191b93194f4f94cf91bc05d8c5b7a3d5d
child 153608 aa71e5360811dad7407af13aba6ea7bf170e300f
push id25596
push userryanvm@gmail.com
push dateTue, 05 Nov 2013 20:28:59 +0000
treeherdermozilla-central@8b89e6626298 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs932309
milestone28.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 932309 - Don't null out mDoc in nsGlobalWindow::FreeInnerObjects, additional fixes. r=smaug.
dom/base/nsGlobalWindow.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -9557,17 +9557,17 @@ nsGlobalWindow::FireHashchange(const nsA
 {
   NS_ENSURE_TRUE(IsInnerWindow(), NS_ERROR_FAILURE);
 
   // Don't do anything if the window is frozen.
   if (IsFrozen())
     return NS_OK;
 
   // Get a presentation shell for use in creating the hashchange event.
-  NS_ENSURE_STATE(mDoc);
+  NS_ENSURE_STATE(IsCurrentInnerWindow());
 
   nsIPresShell *shell = mDoc->GetShell();
   nsRefPtr<nsPresContext> presContext;
   if (shell) {
     presContext = shell->GetPresContext();
   }
 
   // Create a new hashchange event.
@@ -10114,17 +10114,17 @@ nsGlobalWindow::GetInterface(const nsIID
   }
 
   return *aSink ? NS_OK : NS_ERROR_NO_INTERFACE;
 }
 
 void
 nsGlobalWindow::FireOfflineStatusEvent()
 {
-  if (!mDoc)
+  if (!IsCurrentInnerWindow())
     return;
   nsAutoString name;
   if (NS_IsOffline()) {
     name.AssignLiteral("offline");
   } else {
     name.AssignLiteral("online");
   }
   // The event is fired at the body element, or if there is no body element,
@@ -10836,16 +10836,21 @@ nsGlobalWindow::Observe(nsISupports* aSu
       observer->Observe(aSubject, aTopic, aData);
 
     return NS_OK;
   }
 
 #ifdef MOZ_B2G
   if (!nsCRT::strcmp(aTopic, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC) ||
       !nsCRT::strcmp(aTopic, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC)) {
+    MOZ_ASSERT(IsInnerWindow());
+    if (!IsCurrentInnerWindow()) {
+      return NS_OK;
+    }
+
     nsCOMPtr<nsIDOMEvent> event;
     NS_NewDOMEvent(getter_AddRefs(event), this, nullptr, nullptr);
     nsresult rv = event->InitEvent(
       !nsCRT::strcmp(aTopic, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC)
         ? NETWORK_UPLOAD_EVENT_NAME
         : NETWORK_DOWNLOAD_EVENT_NAME,
       false, false);
     NS_ENSURE_SUCCESS(rv, rv);