Modern IDB: storage/indexeddb/delete-in-upgradeneeded-close-in-versionchange.html...
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Dec 2015 01:35:17 +0000 (01:35 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Dec 2015 01:35:17 +0000 (01:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152144

Reviewed by Alex Christensen.

Source/WebCore:

No new tests (At least two failing tests now pass, and other incorrect tests updated to be more correct).

- An IDBOpenDBRequest resulting in a versionchange transaction should not have the onsuccess event fire if
  the database connection was closed during the versionchange transaction. onerror should fire instead.
- When firing an event at an IDBRequest, it should not have the transaction as an additional target if the
  transaction has finished.
- When firing an event at an IDBRequest, it should not have the database as an additional target if the
  database is closed or is closing.

* Modules/indexeddb/client/IDBDatabaseImpl.h:
(WebCore::IDBClient::IDBDatabase::isClosingOrClosed):

* Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp:
(WebCore::IDBClient::IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion):
(WebCore::IDBClient::IDBOpenDBRequest::fireErrorAfterVersionChangeAbort): Deleted.
* Modules/indexeddb/client/IDBOpenDBRequestImpl.h:

* Modules/indexeddb/client/IDBRequestImpl.cpp:
(WebCore::IDBClient::IDBRequest::dispatchEvent): Don't add finished transactions or closed databases as event targets.

* Modules/indexeddb/client/IDBTransactionImpl.cpp:
(WebCore::IDBClient::IDBTransaction::notifyDidAbort):
(WebCore::IDBClient::IDBTransaction::dispatchEvent): If this was a versionchange transaction completing, possibly fire
  the error event on the OpenDBRequest instead of the success event.
* Modules/indexeddb/client/IDBTransactionImpl.h:
(WebCore::IDBClient::IDBTransaction::isFinished):

LayoutTests:

* platform/mac-wk1/TestExpectations:
* storage/indexeddb/modern/abort-requests-cancelled-expected.txt:
* storage/indexeddb/modern/aborted-put-expected.txt:
* storage/indexeddb/modern/createobjectstore-basic-expected.txt:
* storage/indexeddb/modern/deletedatabase-2-expected.txt:
* storage/indexeddb/modern/deletedatabase-2.html:
* storage/indexeddb/modern/deleteindex-2-expected.txt:
* storage/indexeddb/modern/deleteobjectstore-1-expected.txt:
* storage/indexeddb/modern/opendatabase-versions-expected.txt:
* storage/indexeddb/modern/opendatabase-versions.html:
* storage/indexeddb/modern/versionchange-abort-then-reopen-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193936 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/storage/indexeddb/modern/abort-requests-cancelled-expected.txt
LayoutTests/storage/indexeddb/modern/aborted-put-expected.txt
LayoutTests/storage/indexeddb/modern/createobjectstore-basic-expected.txt
LayoutTests/storage/indexeddb/modern/deletedatabase-2-expected.txt
LayoutTests/storage/indexeddb/modern/deletedatabase-2.html
LayoutTests/storage/indexeddb/modern/deleteindex-2-expected.txt
LayoutTests/storage/indexeddb/modern/deleteobjectstore-1-expected.txt
LayoutTests/storage/indexeddb/modern/opendatabase-versions-expected.txt
LayoutTests/storage/indexeddb/modern/opendatabase-versions.html
LayoutTests/storage/indexeddb/modern/versionchange-abort-then-reopen-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.h
Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp
Source/WebCore/Modules/indexeddb/client/IDBOpenDBRequestImpl.h
Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp
Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp
Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h

index bcc651b34828c9d360ec11be490d72ac3e27066f..5779bdae6afa9c9b20582c31d5b75d214fa39712 100644 (file)
@@ -1,3 +1,22 @@
+2015-12-10  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: storage/indexeddb/delete-in-upgradeneeded-close-in-versionchange.html fails
+        https://bugs.webkit.org/show_bug.cgi?id=152144
+
+        Reviewed by Alex Christensen.
+
+        * platform/mac-wk1/TestExpectations:
+        * storage/indexeddb/modern/abort-requests-cancelled-expected.txt:
+        * storage/indexeddb/modern/aborted-put-expected.txt:
+        * storage/indexeddb/modern/createobjectstore-basic-expected.txt:
+        * storage/indexeddb/modern/deletedatabase-2-expected.txt:
+        * storage/indexeddb/modern/deletedatabase-2.html:
+        * storage/indexeddb/modern/deleteindex-2-expected.txt:
+        * storage/indexeddb/modern/deleteobjectstore-1-expected.txt:
+        * storage/indexeddb/modern/opendatabase-versions-expected.txt:
+        * storage/indexeddb/modern/opendatabase-versions.html:
+        * storage/indexeddb/modern/versionchange-abort-then-reopen-expected.txt:
+
 2015-12-10  Ryan Haddad  <ryanhaddad@apple.com>
 
         Rebaselining fast/text/emoji.html for Yosemite.
index 23de56f0a12b9aed6377b1e3b8469aebf66af319..744c382ae08a842d04ef0182d397b3960b270499 100644 (file)
@@ -95,7 +95,6 @@ storage/indexeddb/unblocked-version-changes.html [ Skip ]
 storage/indexeddb/cursor-continue.html [ Failure ]
 storage/indexeddb/database-deletepending-flag.html [ Failure ]
 storage/indexeddb/delete-closed-database-object.html [ Failure ]
-storage/indexeddb/delete-in-upgradeneeded-close-in-versionchange.html [ Failure ]
 storage/indexeddb/index-basics.html [ Failure ]
 storage/indexeddb/index-count.html [ Failure ]
 storage/indexeddb/index-duplicate-keypaths.html [ Failure ]
@@ -109,7 +108,6 @@ storage/indexeddb/intversion-pending-version-changes-same.html [ Failure ]
 storage/indexeddb/intversion-two-opens-no-versions.html [ Failure ]
 storage/indexeddb/intversion-upgrades.html [ Failure ]
 storage/indexeddb/key-type-array.html [ Failure ]
-storage/indexeddb/lazy-index-types.html [ Failure ]
 storage/indexeddb/objectstore-autoincrement.html [ Failure ]
 storage/indexeddb/objectstore-count.html [ Failure ]
 storage/indexeddb/open-cursor.html [ Failure ]
@@ -122,7 +120,6 @@ storage/indexeddb/pending-version-change-stuck.html [ Failure ]
 storage/indexeddb/properties-disabled-at-runtime.html [ Failure ]
 storage/indexeddb/setversion-blocked-by-versionchange-close.html [ Failure ]
 storage/indexeddb/transaction-scope-sequencing.html [ Failure ]
-storage/indexeddb/version-change-abort.html [ Failure ]
 
 # Relies on internals.observeGC
 storage/indexeddb/cursor-leak.html [ Failure ]
index bb01f2b8c663947a75273026f7f985468f85df7c..89c0c7761bbb361f564ff9279e2e58578a4d9045 100644 (file)
@@ -4,7 +4,6 @@ Error handling: "objectStore.put({ bar: 'A' }, 1);" (error)
 Error handling: "objectStore.put({ bar: 'B' }, 2);" (error)
 Error handling: "objectStore.put({ bar: 'C' }, 3);" (error)
 Initial upgrade versionchange transaction aborted
-Initial upgrade versionchange transaction error [object Event]
 Second upgrade needed: Old version - 0 New version - 1
 Success handling: "objectStore.put({ bar: 'A' }, 1);"
 Success handling: "objectStore.put({ bar: 'B' }, 2);"
index 9dad078a96533f739b6d1659f8b76e6098d35725..dd46037fa92b9d8fbcad70c086d06bee1044f342 100644 (file)
@@ -11,7 +11,6 @@ ALERT: [object IDBDatabase]
 ALERT: get1 'foo' succeeded - value was 'baz'
 ALERT: get2 'far' succeeded - value was 'boo'
 ALERT: Second version change transaction abort
-ALERT: Second version change transaction error - [object Event]
 ALERT: Third upgrade needed: Old version - 1 New version - 2
 ALERT: [object IDBTransaction] - versionchange
 ALERT: [object IDBDatabase]
index f15a2ecd2d134bdf7ea17b0bc441c76f3e3807ed..39cfd05dde515598f6f27ca4c7071a4f95606976 100644 (file)
@@ -4,7 +4,6 @@ ALERT: FirstAbortedObjectStore
 ALERT: Put succeeded
 ALERT: Initial upgrade versionchange transaction aborted
 ALERT: Object store names:
-ALERT: Initial upgrade versionchange transaction error [object Event]
 ALERT: Second upgrade needed: Old version - 0 New version - 1
 ALERT: Object store names:
 ALERT: Second upgrade versionchange transaction complete
index 0361b20a0f7102a1fd843fc972c68e46e3341156..4d78a0713d246c10da82fa08a31ab415577fc1d1 100644 (file)
@@ -4,7 +4,7 @@ Initial upgrade old version - 0 new version - 1
 Requesting deleteDatabase
 First connection received versionchange event: oldVersion 1, newVersion null
 First version change complete
-open db success
+Open request error: AbortError
 Delete database success: oldVersion 1, newVersion null
 Recreating database to make sure it's new and empty
 Second upgrade old version - 0 new version - 1
index dd817877eea3da0c1a833166211ea4ca3bc84d2f..b4905890fb5905841ceebe71b19eca2f0fcb2c41 100644 (file)
@@ -29,8 +29,7 @@ request.onsuccess = function()
 }
 request.onerror = function(e)
 {
-    log("Unexpected error");
-       done();
+    log("Open request error: " + request.error.name);
 }
 
 request.onupgradeneeded = function(e)
index a2c4e13ed7c093bacf4f7fc89e0b6b846740ce23..4c7e83db2a67abd4525adb4d53e4c83140aa75fb 100644 (file)
@@ -8,7 +8,6 @@ Second upgrade needed: Old version - 1 New version - 2
 Deleted the index
 Aborted the transaction
 Second upgrade versionchange transaction abort
-Second upgrade versionchange transaction error [object Event]
 Third upgrade needed: Old version - 1 New version - 3
 Count is: 2
 Cursor at record: A / 1
index 88bc9d46a8f2661d43e3cbb4bdf3aa2e7168711e..3a5e343b728735f8ffc59bebd9d4756742f4cc35 100644 (file)
@@ -4,7 +4,6 @@ ALERT: Second upgrade needed: Old version - 1 New version - 2
 ALERT: Deleting object store
 ALERT: Second version change transaction abort
 ALERT: Request error - [object Event]
-ALERT: Second version change transaction error - [object Event]
 ALERT: Success opening database connection - Starting final transaction
 ALERT: Value gotten was AH AH AH AH AH
 ALERT: Value gotten was AH AH AH AH AH
index caa11d0501babf7a3931b91ff79cc261707abfbd..9f0ae21dbd14ad2a56a08adee9ce7bdfa4af2c01 100644 (file)
@@ -1,17 +1,18 @@
-ALERT: [object IDBOpenDBRequest] (firstPhase)
-ALERT: upgradeneeded (firstPhase): old version - 0 new version - 1
-ALERT: [object IDBTransaction]
-ALERT: Version change complete (firstPhase). Database version is now - 1
-ALERT: [object IDBOpenDBRequest] (secondPhase)
-ALERT: First version change successful
-ALERT: Successfully opened database at version 1 (secondPhase)
-ALERT: [object IDBOpenDBRequest] (thirdPhase)
-ALERT: upgradeneeded (thirdPhase): old version - 1 new version - 2
-ALERT: [object IDBTransaction]
-ALERT: Version change complete (thirdPhase). Database version is now - 2
-ALERT: [object IDBOpenDBRequest] (fourthPhase)
-ALERT: Version change to version 2 successful
-ALERT: Expected error (fourthPhase) - VersionError
-ALERT: Done
 This test creates a new database with the default version, commits that versionchange transaction, and then reopens it at different versions to make sure the IDBOpenDBRequests behave appropriately.
+[object IDBOpenDBRequest] (firstPhase)
+upgradeneeded (firstPhase): old version - 0 new version - 1
+[object IDBTransaction]
+Version change complete (firstPhase). Database version is now - 1
+[object IDBOpenDBRequest] (secondPhase)
+Open request error (firstPhase) AbortError
+Successfully opened database at version 1 (secondPhase)
+[object IDBOpenDBRequest] (thirdPhase)
+upgradeneeded (thirdPhase): old version - 1 new version - 2
+[object IDBTransaction]
+Version change complete (thirdPhase). Database version is now - 2
+[object IDBOpenDBRequest] (fourthPhase)
+Open request error (thirdPhase) AbortError
+Expected error (fourthPhase) - VersionError
+Done
+
 
index dc6e171e2d14832aa70186354038c15e28bd86f0..dbf9c516fb2d16fcfee3e0d73b77f2c5bb57160e 100644 (file)
@@ -1,6 +1,12 @@
 This test creates a new database with the default version, commits that versionchange transaction, and then reopens it at different versions to make sure the IDBOpenDBRequests behave appropriately.<br>
+<div id="logger"></div><br>
 <script>
 
+function log(msg)
+{
+    document.getElementById("logger").innerHTML += msg + "<br>";
+}
+
 if (window.testRunner) {
     testRunner.waitUntilDone();
     testRunner.dumpAsText();
@@ -8,44 +14,43 @@ if (window.testRunner) {
 
 function done()
 {
-    alert("Done");
+    log("Done");
     if (window.testRunner)
         testRunner.notifyDone();
 }
 
 var request = window.indexedDB.open("VersionTestDatabase");
-alert(request + " (firstPhase)");
+log(request + " (firstPhase)");
 
 request.onsuccess = function()
 {
-    alert("First version change successful");
+    log("First version change successful");
 }
 request.onerror = function(e)
 {
-    alert("Unexpected error (firstPhase)");
-       done();
+    log("Open request error (firstPhase) " + request.error.name);
 }
 
 request.onupgradeneeded = function(e)
 {
     var database = event.target.result;
 
-    alert("upgradeneeded (firstPhase): old version - " + e.oldVersion + " new version - " + e.newVersion);
-    alert(request.transaction);
+    log("upgradeneeded (firstPhase): old version - " + e.oldVersion + " new version - " + e.newVersion);
+    log(request.transaction);
     request.transaction.oncomplete = function()
     {
-        alert("Version change complete (firstPhase). Database version is now - " + database.version);
+        log("Version change complete (firstPhase). Database version is now - " + database.version);
         database.close();
         secondPhase();
     }
     request.transaction.onabort = function()
     {
-        alert("Version change transaction unexpected abort! (firstPhase)");
+        log("Version change transaction unexpected abort! (firstPhase)");
         done();
     }
     request.transaction.onerror = function()
     {
-        alert("Version change transaction unexpected error! (firstPhase)");
+        log("Version change transaction unexpected error! (firstPhase)");
         done();
     }
 }
@@ -53,22 +58,22 @@ request.onupgradeneeded = function(e)
 function secondPhase()
 {
     var request = window.indexedDB.open("VersionTestDatabase", 1);
-    alert(request + " (secondPhase)");
+    log(request + " (secondPhase)");
     request.onsuccess = function()
     {
-        alert("Successfully opened database at version 1 (secondPhase)");
+        log("Successfully opened database at version 1 (secondPhase)");
         request.result.close();
         request.result.close(); // Close it twice just for the heck of it
         thirdPhase();
     }
     request.onerror = function(e)
     {
-        alert("Unexpected error (secondPhase)" + e);
+        log("Unexpected error (secondPhase)" + e);
         done();
     }
     request.onupgradeneeded = function(e)
     {
-       alert("Unexpected upgrade needed (secondPhase)" + e);
+       log("Unexpected upgrade needed (secondPhase)" + e);
        done();
     }
 }
@@ -76,36 +81,35 @@ function secondPhase()
 function thirdPhase()
 {
     var request = window.indexedDB.open("VersionTestDatabase", 2);
-    alert(request + " (thirdPhase)");
+    log(request + " (thirdPhase)");
     request.onsuccess = function()
     {
-        alert("Version change to version 2 successful");
+        log("Version change to version 2 successful");
     }
     request.onerror = function(e)
     {
-        alert("Unexpected error (thirdPhase)");
-        done();
+        log("Open request error (thirdPhase) " + request.error.name);
     }
     request.onupgradeneeded = function(e)
     {
         var database = event.target.result;
 
-        alert("upgradeneeded (thirdPhase): old version - " + e.oldVersion + " new version - " + e.newVersion);
-        alert(request.transaction);
+        log("upgradeneeded (thirdPhase): old version - " + e.oldVersion + " new version - " + e.newVersion);
+        log(request.transaction);
         request.transaction.oncomplete = function()
         {
-            alert("Version change complete (thirdPhase). Database version is now - " + database.version);
+            log("Version change complete (thirdPhase). Database version is now - " + database.version);
             database.close();
             fourthPhase();
         }
         request.transaction.onabort = function()
         {
-            alert("Version change transaction unexpected abort! (thirdPhase)");
+            log("Version change transaction unexpected abort! (thirdPhase)");
             done();
         }
         request.transaction.onerror = function()
         {
-            alert("Version change transaction unexpected error! (thirdPhase)");
+            log("Version change transaction unexpected error! (thirdPhase)");
             done();
         }
     } 
@@ -115,20 +119,20 @@ function fourthPhase()
 {
     // We've upgraded to version 2, so version 1 should not be openable.
     var request = window.indexedDB.open("VersionTestDatabase", 1);
-    alert(request + " (fourthPhase)");
+    log(request + " (fourthPhase)");
     request.onsuccess = function()
     {
-        alert("Unexpected success (fourthPhase)");
+        log("Unexpected success (fourthPhase)");
         done();
     }
     request.onerror = function(e)
     {
-        alert("Expected error (fourthPhase) - " + request.error.name);
+        log("Expected error (fourthPhase) - " + request.error.name);
         done();
     }
     request.onupgradeneeded = function(e)
     {
-        alert("Unexpected upgradeneeded (fourthPhase)");
+        log("Unexpected upgradeneeded (fourthPhase)");
         done();
     } 
 }
index 71ab9f052d3284fdc670af437746a7a6ad40c39a..fa69783b9b8676e6615de8053b8e52a9d9a59933 100644 (file)
@@ -1,11 +1,9 @@
 ALERT: Initial upgrade needed: Old version - 0 New version - 1
 ALERT: Initial upgrade versionchange transaction aborted
-ALERT: Initial upgrade versionchange transaction error [object Event]
 ALERT: Second upgrade needed: Old version - 0 New version - 1
 ALERT: Second upgrade versionchange transaction complete
 ALERT: Third upgrade needed: Old version - 1 New version - 2
 ALERT: Third upgrade versionchange transaction aborted
-ALERT: Third upgrade versionchange transaction error[object Event]
 ALERT: Fourth upgrade needed: Old version - 1 New version - 2
 ALERT: Done
 This test opens a new database, then aborts the version change transaction.
index b62299ac444d1446dc53369cf5b814727ef33359..2f381a9e8953ab1b82196aaa99c72c1d9defa9da 100644 (file)
@@ -1,3 +1,37 @@
+2015-12-10  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: storage/indexeddb/delete-in-upgradeneeded-close-in-versionchange.html fails
+        https://bugs.webkit.org/show_bug.cgi?id=152144
+
+        Reviewed by Alex Christensen.
+
+        No new tests (At least two failing tests now pass, and other incorrect tests updated to be more correct).
+
+        - An IDBOpenDBRequest resulting in a versionchange transaction should not have the onsuccess event fire if 
+          the database connection was closed during the versionchange transaction. onerror should fire instead.
+        - When firing an event at an IDBRequest, it should not have the transaction as an additional target if the
+          transaction has finished.
+        - When firing an event at an IDBRequest, it should not have the database as an additional target if the
+          database is closed or is closing.
+
+        * Modules/indexeddb/client/IDBDatabaseImpl.h:
+        (WebCore::IDBClient::IDBDatabase::isClosingOrClosed):
+        
+        * Modules/indexeddb/client/IDBOpenDBRequestImpl.cpp:
+        (WebCore::IDBClient::IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion):
+        (WebCore::IDBClient::IDBOpenDBRequest::fireErrorAfterVersionChangeAbort): Deleted.
+        * Modules/indexeddb/client/IDBOpenDBRequestImpl.h:
+        
+        * Modules/indexeddb/client/IDBRequestImpl.cpp:
+        (WebCore::IDBClient::IDBRequest::dispatchEvent): Don't add finished transactions or closed databases as event targets.
+        
+        * Modules/indexeddb/client/IDBTransactionImpl.cpp:
+        (WebCore::IDBClient::IDBTransaction::notifyDidAbort):
+        (WebCore::IDBClient::IDBTransaction::dispatchEvent): If this was a versionchange transaction completing, possibly fire
+          the error event on the OpenDBRequest instead of the success event.
+        * Modules/indexeddb/client/IDBTransactionImpl.h:
+        (WebCore::IDBClient::IDBTransaction::isFinished):
+
 2015-12-10  Zalan Bujtas  <zalan@apple.com>
 
         Simple line layout: Use TextPainter to draw simple line text.
index 241a26e6733599c634aa23092550e56f71c1f7a9..f08b1af20193acb9b087ccfc6f403b5369ae2baf 100644 (file)
@@ -87,6 +87,8 @@ public:
     void didCreateIndexInfo(const IDBIndexInfo&);
     void didDeleteIndexInfo(const IDBIndexInfo&);
 
+    bool isClosingOrClosed() const { return m_closePending || m_closedInServer; }
+
 private:
     IDBDatabase(ScriptExecutionContext&, IDBConnectionToServer&, const IDBResultData&);
 
index 57c7a7af08a322294f10d2bdc6dbb64fb44129e1..4239d4c42a6a486b35333f2956bf145319c68fbb 100644 (file)
@@ -86,14 +86,15 @@ void IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit()
     enqueueEvent(Event::create(eventNames().successEvent, false, false));
 }
 
-void IDBOpenDBRequest::fireErrorAfterVersionChangeAbort()
+void IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion()
 {
-    LOG(IndexedDB, "IDBOpenDBRequest::fireErrorAfterVersionChangeAbort()");
+    LOG(IndexedDB, "IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion()");
 
     ASSERT(hasPendingActivity());
 
     IDBError idbError(IDBDatabaseException::AbortError);
     m_domError = DOMError::create(idbError.name());
+    m_result = IDBAny::createUndefined();
 
     m_transaction->addRequest(*this);
     enqueueEvent(Event::create(eventNames().errorEvent, true, true));
index 46ae97c74c435a3cbfe723244e269175ccb07ec4..a2cf441cb5582e188442699e3ebb09e6c3d339ab 100644 (file)
@@ -55,7 +55,7 @@ public:
 
     void versionChangeTransactionWillFinish();
     void fireSuccessAfterVersionChangeCommit();
-    void fireErrorAfterVersionChangeAbort();
+    void fireErrorAfterVersionChangeCompletion();
 
 private:
     IDBOpenDBRequest(IDBConnectionToServer&, ScriptExecutionContext*, const IDBDatabaseIdentifier&, uint64_t version);
index 5af8760e28a4947309b9a8dbe9ea7a53606615dd..03c2f9a2c7930423d6d017eb2334a0fc3b281b95 100644 (file)
@@ -266,8 +266,10 @@ bool IDBRequest::dispatchEvent(Event& event)
     targets.append(this);
 
     if (m_transaction) {
-        targets.append(m_transaction);
-        targets.append(m_transaction->db());
+        if (!m_transaction->isFinished())
+            targets.append(m_transaction);
+        if (!m_transaction->database().isClosingOrClosed())
+            targets.append(m_transaction->db());
     }
 
     m_hasPendingActivity = false;
index 44593607b14ce6e93cdc557cbf0bf38687d1bd92..38d4f337307a6256e43e722d51c38b0ade0aabe8 100644 (file)
@@ -356,7 +356,7 @@ void IDBTransaction::notifyDidAbort(const IDBError& error)
 
     if (isVersionChange()) {
         ASSERT(m_openDBRequest);
-        m_openDBRequest->fireErrorAfterVersionChangeAbort();
+        m_openDBRequest->fireErrorAfterVersionChangeCompletion();
     }
 }
 
@@ -427,7 +427,11 @@ bool IDBTransaction::dispatchEvent(Event& event)
 
     if (isVersionChange() && event.type() == eventNames().completeEvent) {
         ASSERT(m_openDBRequest);
-        m_openDBRequest->fireSuccessAfterVersionChangeCommit();
+
+        if (m_database->isClosingOrClosed())
+            m_openDBRequest->fireErrorAfterVersionChangeCompletion();
+        else
+            m_openDBRequest->fireSuccessAfterVersionChangeCommit();
     }
 
     return result;
index 7e078ea92fc9e53c67dac739dcc22ac0bf3a8484..5dac553d4b36044ae38ef23b77b01c50b62c74a6 100644 (file)
@@ -127,6 +127,7 @@ public:
     void operationDidComplete(TransactionOperation&);
 
     bool isFinishedOrFinishing() const;
+    bool isFinished() const { return m_state == IndexedDB::TransactionState::Finished; }
 
 private:
     IDBTransaction(IDBDatabase&, const IDBTransactionInfo&, IDBOpenDBRequest*);