Bug 1067568 - Intermittent test_filehandle_readonly_exceptions.html | Assertion count 4 is greater than expected (ASSERTION: We don't know anyting about this file handle?!: 'Error', file dom/filehandle/FileService.cpp, line 234); r=bent
authorJan Varga <jan.varga@gmail.com>
Mon, 02 Mar 2015 22:14:22 +0100
changeset 246969 3816bf636b009aa61549ebea25972900c9c57223
parent 246968 1fb224ec0020bf278e7f7c0584f4ef8217a88f4e
child 246970 4ef647d61d1f919a8258f0130be7ef133e624cbb
push id884
push userdburns@mozilla.com
push dateTue, 03 Mar 2015 15:29:12 +0000
reviewersbent
bugs1067568
milestone39.0a1
Bug 1067568 - Intermittent test_filehandle_readonly_exceptions.html | Assertion count 4 is greater than expected (ASSERTION: We don't know anyting about this file handle?!: 'Error', file dom/filehandle/FileService.cpp, line 234); r=bent
dom/indexedDB/IDBMutableFile.cpp
--- a/dom/indexedDB/IDBMutableFile.cpp
+++ b/dom/indexedDB/IDBMutableFile.cpp
@@ -314,21 +314,23 @@ IDBMutableFile::Open(FileMode aMode, Err
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (QuotaManager::IsShuttingDown() || FileService::IsShuttingDown()) {
     aError.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
     return nullptr;
   }
 
-  if (mInvalidated) {
+  if (mDatabase->IsClosed()) {
     aError.Throw(NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR);
     return nullptr;
   }
 
+  MOZ_ASSERT(GetOwner());
+
   nsRefPtr<IDBFileHandle> fileHandle =
     IDBFileHandle::Create(aMode, FileHandleBase::NORMAL, this);
   if (!fileHandle) {
     aError.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
     return nullptr;
   }
 
   return fileHandle.forget();
@@ -359,21 +361,28 @@ IDBMutableFile::CreateFileObject(IDBFile
   return fileSnapshot.forget();
 }
 
 already_AddRefed<DOMRequest>
 IDBMutableFile::GetFile(ErrorResult& aError)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  // Do nothing if the window is closed
-  if (!GetOwner()) {
+  if (QuotaManager::IsShuttingDown() || FileService::IsShuttingDown()) {
+    aError.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
     return nullptr;
   }
 
+  if (mDatabase->IsClosed()) {
+    aError.Throw(NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR);
+    return nullptr;
+  }
+
+  MOZ_ASSERT(GetOwner());
+
   nsRefPtr<IDBFileHandle> fileHandle =
     IDBFileHandle::Create(FileMode::Readonly, FileHandleBase::PARALLEL, this);
 
   nsRefPtr<IDBFileRequest> request = 
     IDBFileRequest::Create(GetOwner(),
                            fileHandle,
                            /* aWrapAsDOMRequest */ true);