Bug 747247: Fix assertions about null owners. r=khuey
authorBen Turner <bent.mozilla@gmail.com>
Wed, 16 May 2012 15:08:18 -0700
changeset 94186 5e462ce3cb42041ddb0776113a899e3eefdc89c0
parent 94185 cdfc4be453d6f072c76437b2b9f05cfa326f4e0f
child 94187 eea44303caab054540fb6ee9b165a264c83e6a7a
push id9504
push userryanvm@gmail.com
push dateThu, 17 May 2012 00:46:10 +0000
treeherdermozilla-inbound@bd69b36934cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs747247
milestone15.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 747247: Fix assertions about null owners. r=khuey
dom/indexedDB/IDBDatabase.cpp
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -107,17 +107,17 @@ public:
 
   nsresult OnSuccess()
   {
     return NS_OK;
   }
 
   void OnError()
   {
-    NS_ASSERTION(mTransaction->IsAborted(), "How else can this fail?!");
+    NS_ASSERTION(mTransaction->IsAborted(), "How elsehttps://bugzilla.mozilla.org/attachment.cgi?id=616806 can this fail?!");
   }
 
 private:
   // In-params.
   PRInt64 mObjectStoreId;
 };
 
 NS_STACK_CLASS
@@ -217,17 +217,20 @@ IDBDatabase::Invalidate()
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   // Make sure we're closed too.
   Close();
 
   // When the IndexedDatabaseManager needs to invalidate databases, all it has
   // is an origin, so we call back into the manager to cancel any prompts for
   // our owner.
-  IndexedDatabaseManager::CancelPromptsForWindow(GetOwner());
+  nsPIDOMWindow* owner = GetOwner();
+  if (owner) {
+    IndexedDatabaseManager::CancelPromptsForWindow(owner);
+  }
 
   mInvalidated = true;
 }
 
 bool
 IDBDatabase::IsInvalidated()
 {
   return !!mInvalidated;
@@ -279,18 +282,16 @@ IDBDatabase::ExitSetVersionTransaction()
   NS_ASSERTION(mRunningVersionChange, "How did that happen?");
   mRunningVersionChange = false;
 }
 
 void
 IDBDatabase::OnUnlink()
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-  NS_ASSERTION(!GetOwner() && !GetScriptOwner(),
-               "Should have been cleared already!");
 
   // We've been unlinked, at the very least we should be able to prevent further
   // transactions from starting and unblock any other SetVersion callers.
   CloseInternal(true);
 
   // No reason for the IndexedDatabaseManager to track us any longer.
   IndexedDatabaseManager* mgr = IndexedDatabaseManager::Get();
   if (mgr) {
@@ -675,31 +676,32 @@ IDBDatabase::Close()
   return NS_OK;
 }
 
 nsresult
 IDBDatabase::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
 {
   NS_ENSURE_TRUE(aVisitor.mDOMEvent, NS_ERROR_UNEXPECTED);
 
-  if (!GetOwner()) {
+  nsPIDOMWindow* owner = GetOwner();
+  if (!owner) {
     return NS_OK;
   }
 
   if (aVisitor.mEventStatus != nsEventStatus_eConsumeNoDefault) {
     nsString type;
     nsresult rv = aVisitor.mDOMEvent->GetType(type);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (type.EqualsLiteral(ERROR_EVT_STR)) {
       nsRefPtr<nsDOMEvent> duplicateEvent =
         CreateGenericEvent(type, eDoesNotBubble, eNotCancelable);
       NS_ENSURE_STATE(duplicateEvent);
 
-      nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(GetOwner()));
+      nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(owner));
       NS_ASSERTION(target, "How can this happen?!");
 
       bool dummy;
       rv = target->DispatchEvent(duplicateEvent, &dummy);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }