Modern IDB: Blocked event can fire on a delete request even after the last open conne...
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jan 2016 21:12:08 +0000 (21:12 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jan 2016 21:12:08 +0000 (21:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152896

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* indexeddb/idbfactory_open12-expected.txt:
* indexeddb/idbversionchangeevent-expected.txt:
* indexeddb/transaction-lifetime-expected.txt:

Source/WebCore:

No new tests (Progression in many tests).

* Modules/indexeddb/client/IDBFactoryImpl.cpp:
(WebCore::IDBClient::IDBFactory::deleteDatabase):

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::performCurrentDeleteOperation): Allow for handling 2+ delete operations in a row.
(WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): Ditto.
(WebCore::IDBServer::UniqueIDBDatabase::connectionClosedFromClient): Call "notifyCurrentRequestConnectionClosedOrFiredVersionChangeEvent"
  after the connection is actually removed from the set of open connections.
* Modules/indexeddb/server/UniqueIDBDatabase.h:

LayoutTests:

* platform/mac-wk1/TestExpectations:

* platform/wk2/imported/w3c/indexeddb/idbfactory_open12-expected.txt: Copied from LayoutTests/imported/w3c/indexeddb/idbfactory_open12-expected.txt.
* platform/wk2/imported/w3c/indexeddb/idbversionchangeevent-expected.txt: Copied from LayoutTests/imported/w3c/indexeddb/idbversionchangeevent-expected.txt.

* storage/indexeddb/database-wrapper-expected.txt:
* storage/indexeddb/delete-in-upgradeneeded-close-in-versionchange-expected.txt:
* storage/indexeddb/deletedatabase-not-blocked-expected.txt:
* storage/indexeddb/intversion-upgrades-expected.txt:
* storage/indexeddb/resources/delete-in-upgradeneeded-close-in-versionchange.js:
* storage/indexeddb/resources/deletedatabase-not-blocked.js:
* storage/indexeddb/resources/setversion-not-blocked.js:
* storage/indexeddb/setversion-not-blocked-expected.txt:

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/indexeddb/idbfactory_open12-expected.txt
LayoutTests/imported/w3c/indexeddb/idbversionchangeevent-expected.txt
LayoutTests/imported/w3c/indexeddb/transaction-lifetime-expected.txt
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/wk2/imported/w3c/indexeddb/idbfactory_open12-expected.txt [new file with mode: 0644]
LayoutTests/platform/wk2/imported/w3c/indexeddb/idbversionchangeevent-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/database-wrapper-expected.txt
LayoutTests/storage/indexeddb/delete-in-upgradeneeded-close-in-versionchange-expected.txt
LayoutTests/storage/indexeddb/deletedatabase-not-blocked-expected.txt
LayoutTests/storage/indexeddb/intversion-upgrades-expected.txt
LayoutTests/storage/indexeddb/resources/delete-in-upgradeneeded-close-in-versionchange.js
LayoutTests/storage/indexeddb/resources/deletedatabase-not-blocked.js
LayoutTests/storage/indexeddb/resources/setversion-not-blocked.js
LayoutTests/storage/indexeddb/setversion-not-blocked-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/client/IDBFactoryImpl.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h

index 30fcf29f38fcc44d37386ea1583045474bd1e378..eb3fbbdd1dad6342b9d0ec83dfa536c1ebd5d0f5 100644 (file)
@@ -1,3 +1,24 @@
+2016-01-08  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Blocked event can fire on a delete request even after the last open connection has closed.
+        https://bugs.webkit.org/show_bug.cgi?id=152896
+
+        Reviewed by Alex Christensen.
+
+        * platform/mac-wk1/TestExpectations:
+        
+        * platform/wk2/imported/w3c/indexeddb/idbfactory_open12-expected.txt: Copied from LayoutTests/imported/w3c/indexeddb/idbfactory_open12-expected.txt.
+        * platform/wk2/imported/w3c/indexeddb/idbversionchangeevent-expected.txt: Copied from LayoutTests/imported/w3c/indexeddb/idbversionchangeevent-expected.txt.
+        
+        * storage/indexeddb/database-wrapper-expected.txt:
+        * storage/indexeddb/delete-in-upgradeneeded-close-in-versionchange-expected.txt:
+        * storage/indexeddb/deletedatabase-not-blocked-expected.txt:
+        * storage/indexeddb/intversion-upgrades-expected.txt:
+        * storage/indexeddb/resources/delete-in-upgradeneeded-close-in-versionchange.js:
+        * storage/indexeddb/resources/deletedatabase-not-blocked.js:
+        * storage/indexeddb/resources/setversion-not-blocked.js:
+        * storage/indexeddb/setversion-not-blocked-expected.txt:
+
 2016-01-08  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Several animation tests fail with accelerated compositing enabled
index ed1e3a6bc3b9c6566a04403a5265f1566c5ec1a2..78e2d005e3f65025123384e75115b209316bae3b 100644 (file)
@@ -1,3 +1,14 @@
+2016-01-08  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Blocked event can fire on a delete request even after the last open connection has closed.
+        https://bugs.webkit.org/show_bug.cgi?id=152896
+
+        Reviewed by Alex Christensen.
+
+        * indexeddb/idbfactory_open12-expected.txt:
+        * indexeddb/idbversionchangeevent-expected.txt:
+        * indexeddb/transaction-lifetime-expected.txt:
+
 2016-01-08  Brady Eidson  <beidson@apple.com>
 
         Modern IDB: imported/w3c/indexeddb/idbobjectstore_createIndex6-event_order.htm fails.
index bf86e7002a3d59d43aba47fdc7628b1175238946..d91bb27f5afa867aab1007537c3c7a2cfe2c5d6f 100644 (file)
@@ -1,4 +1,4 @@
 
 PASS IDBFactory.open() - upgradeneeded gets VersionChangeEvent 
-FAIL IDBFactory.open() - upgradeneeded gets VersionChangeEvent - second upgrade assert_unreached: unexpected open.blocked event Reached unreachable code
+PASS IDBFactory.open() - upgradeneeded gets VersionChangeEvent - second upgrade 
 
index 833b8469b31111285dcef35192de0eba39392f7c..ff2e83294bd853b5b214eeeaa0d3e1834923d4b9 100644 (file)
@@ -1,3 +1,3 @@
 
-FAIL IDBVersionChangeEvent fired in upgradeneeded, versionchange and deleteDatabase assert_equals: new version (versionchange) expected (object) null but got (number) 0
+PASS IDBVersionChangeEvent fired in upgradeneeded, versionchange and deleteDatabase 
 
index 5234708f7ebc8b2d24aa5c58eeaa80e09ab5fa93..3ab3fdd457f647d0bf988c7792b61e0bde85c469 100644 (file)
@@ -1,3 +1,3 @@
 
-FAIL Test events opening a second database when one connection is open already assert_unreached: open2.blocked Reached unreachable code
+PASS Test events opening a second database when one connection is open already 
 
index 0400307be379a5ac8f8cc00fd9863c745b4421e0..e05d389e25b30d591033a067199deed049d4ad63 100644 (file)
@@ -74,7 +74,6 @@ imported/w3c/indexeddb/interfaces.html [ Skip ]
 imported/w3c/indexeddb/keyorder.htm [ Skip ]
 
 # W3C IDB tests - Legacy IDB fails, Modern IDB fails differently
-imported/w3c/indexeddb/idbversionchangeevent.htm [ Failure ]
 imported/w3c/indexeddb/keypath.htm [ Failure ]
 
 # W3C IDB tests where the test is wrong (the spec, other browsers, and WebKit all agree)
diff --git a/LayoutTests/platform/wk2/imported/w3c/indexeddb/idbfactory_open12-expected.txt b/LayoutTests/platform/wk2/imported/w3c/indexeddb/idbfactory_open12-expected.txt
new file mode 100644 (file)
index 0000000..bf86e70
--- /dev/null
@@ -0,0 +1,4 @@
+
+PASS IDBFactory.open() - upgradeneeded gets VersionChangeEvent 
+FAIL IDBFactory.open() - upgradeneeded gets VersionChangeEvent - second upgrade assert_unreached: unexpected open.blocked event Reached unreachable code
+
diff --git a/LayoutTests/platform/wk2/imported/w3c/indexeddb/idbversionchangeevent-expected.txt b/LayoutTests/platform/wk2/imported/w3c/indexeddb/idbversionchangeevent-expected.txt
new file mode 100644 (file)
index 0000000..833b846
--- /dev/null
@@ -0,0 +1,3 @@
+
+FAIL IDBVersionChangeEvent fired in upgradeneeded, versionchange and deleteDatabase assert_equals: new version (versionchange) expected (object) null but got (number) 0
+
index 5b2c73be6ed7b36a492892698093d993d840b7da..b5c80ae072500708aba1ce8c82045a8c6ad0d18a 100644 (file)
@@ -27,9 +27,6 @@ onVersionChange():
 event.target.close()
 sawVersionChangeEvent = true
 
-onBlocked():
-FIXME: Blocked event shouldn't fire. http://crbug.com/100123
-
 openAgainSuccess():
 PASS sawVersionChangeEvent is true
 PASS successfullyParsed is true
index c2e07a74f8b9637286919f8944cf2cf633e7b906..fd7c297a56fe74bf929148bb8677ab85d6b138e9 100644 (file)
@@ -27,14 +27,9 @@ sawVersionChange = true
 Closing the connection before the IDBOpenDBRequest's success fires will cause the open to fail.
 db.close()
 
-deleteBlockedCallback():
-PASS sawVersionChange is true
-sawDeleteBlocked = true
-
 deleteSuccessCallback():
 PASS sawVersionChange is true
-FIXME: Blocked events shouldn't fire if connections close in versionchange handler. http://crbug.com/100123
-FAIL sawDeleteBlocked should be false. Was true.
+PASS sawDeleteBlocked is false
 PASS sawUpgradeNeeded is true
 PASS successfullyParsed is true
 
index 142ce58374a3eba51868b865a4cadd4447455e4e..09c0d6d3fd16eaa7cd94eab489269dab4a54a7cd 100644 (file)
@@ -19,12 +19,8 @@ PASS event.oldVersion is 1
 PASS event.newVersion is null
 h.close()
 
-deleteDatabaseOnBlocked():
-blockedEventFired = true
-
 deleteDatabaseOnSuccess():
-FIXME: blocked event should not fire since connection closed. http://webkit.org/b/71130
-FAIL blockedEventFired should be false. Was true.
+PASS blockedEventFired is false
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 794b516629cb1cc519141ad2a535ad7bc159d5e3..1f44def6297f6e2e22ee086fc85b31f38e81f44a 100644 (file)
@@ -23,9 +23,6 @@ request = indexedDB.open(dbname, 2)
 connection1VersionChangeCallback():
 connection1.close()
 
-connection2BlockedCallback():
-This should not be called: http://crbug.com/100123
-
 connection2UpgradeNeeded():
 connection2 = event.target.result
 PASS String(connection2) is "[object IDBDatabase]"
index 1b460adbbe115343ac764c7db0a87a8b06cfc3e5..38cecffcbd623716a45243fedecdcd1bd7e7cb98 100644 (file)
@@ -63,7 +63,6 @@ function deleteSuccessCallback(evt)
 {
     preamble(evt);
     shouldBeTrue("sawVersionChange");
-    debug("FIXME: Blocked events shouldn't fire if connections close in versionchange handler. http://crbug.com/100123");
     shouldBeFalse("sawDeleteBlocked");
     shouldBeTrue("sawUpgradeNeeded");
     finishJSTest();
index d2b1c0ee397912a6ec65d326c88c08ab06de6c23..24321d02eb5d4c426766ba0bf06e2366be4cfa39 100644 (file)
@@ -34,7 +34,6 @@ function test() {
         };
         request.onsuccess = function deleteDatabaseOnSuccess(evt) {
             preamble(evt);
-            debug("FIXME: blocked event should not fire since connection closed. http://webkit.org/b/71130");
             shouldBeFalse("blockedEventFired");
             finishJSTest();
         };
index a325dccddcadbd0d85d579bfaa072b04373737c3..981f48bcbfba0cdadd0c9bd702b4d5cdeea40c2a 100644 (file)
@@ -42,7 +42,6 @@ function onOpen(evt)
     request.onsuccess = function h2OpenSuccess(evt) {
         preamble(evt);
         shouldBeTrue("versionchangeEventFired");
-        debug("FIXME: blocked should not have fired since connection closed; http://webkit.org/b/71130");
         shouldBeFalse("blockedEventFired");
         finishJSTest();
     };
index 977f23da8771202e34ab7bf28b8759ee88c100e7..c6c8b23c8f931ee110d4ff3dbfd9e57600ca869a 100644 (file)
@@ -22,19 +22,13 @@ PASS event.oldVersion is 1
 PASS event.newVersion is 2
 h1.close()
 
-h2OpenBlocked():
-PASS event.oldVersion is 1
-PASS event.newVersion is 2
-blockedEventFired = true
-
 h2UpgradeNeeded():
 PASS event.oldVersion is 1
 PASS event.newVersion is 2
 
 h2OpenSuccess():
 PASS versionchangeEventFired is true
-FIXME: blocked should not have fired since connection closed; http://webkit.org/b/71130
-FAIL blockedEventFired should be false. Was true.
+PASS blockedEventFired is false
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 24aaae3ea88aefca92753141a675c0ff2723a2b2..24672172736862d28300d9a781cb612a5cbfc0d0 100644 (file)
@@ -1,3 +1,22 @@
+2016-01-08  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Blocked event can fire on a delete request even after the last open connection has closed.
+        https://bugs.webkit.org/show_bug.cgi?id=152896
+
+        Reviewed by Alex Christensen.
+
+        No new tests (Progression in many tests).
+
+        * Modules/indexeddb/client/IDBFactoryImpl.cpp:
+        (WebCore::IDBClient::IDBFactory::deleteDatabase):
+        
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabase::performCurrentDeleteOperation): Allow for handling 2+ delete operations in a row.
+        (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): Ditto.
+        (WebCore::IDBServer::UniqueIDBDatabase::connectionClosedFromClient): Call "notifyCurrentRequestConnectionClosedOrFiredVersionChangeEvent"
+          after the connection is actually removed from the set of open connections.
+        * Modules/indexeddb/server/UniqueIDBDatabase.h:
+
 2016-01-08  Zalan Bujtas  <zalan@apple.com>
 
         Hovering link on http://help.apple.com/appletv/#/ does not show text underline.
index fda69b524ae1a91d5fc2a03e7c658b195724c5be..2ae26932093f06672d16cb1d9306475fad9b286a 100644 (file)
@@ -124,7 +124,7 @@ RefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext* contex
 
 RefPtr<WebCore::IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
 {
-    LOG(IndexedDB, "IDBFactory::deleteDatabase");
+    LOG(IndexedDB, "IDBFactory::deleteDatabase - %s", name.utf8().data());
 
     if (name.isNull()) {
         ec = TypeError;
index 7c86eaccbd8148af5f23db755ff8edfb0df589b9..223239b6f66e5a1e4f3ff258c2254641455617f8 100644 (file)
@@ -164,9 +164,8 @@ void UniqueIDBDatabase::performCurrentOpenOperation()
 void UniqueIDBDatabase::performCurrentDeleteOperation()
 {
     ASSERT(isMainThread());
-    LOG(IndexedDB, "(main) UniqueIDBDatabase::performCurrentDeleteOperation");
+    LOG(IndexedDB, "(main) UniqueIDBDatabase::performCurrentDeleteOperation - %s", m_identifier.debugString().utf8().data());
 
-    ASSERT(m_databaseInfo);
     ASSERT(m_currentOpenDBRequest);
     ASSERT(m_currentOpenDBRequest->isDeleteRequest());
 
@@ -189,8 +188,17 @@ void UniqueIDBDatabase::performCurrentDeleteOperation()
     ASSERT(m_pendingTransactions.isEmpty());
     ASSERT(m_openDatabaseConnections.isEmpty());
 
-    m_deleteBackingStoreInProgress = true;
-    m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::deleteBackingStore));
+    // It's possible to have multiple delete requests queued up in a row.
+    // In that scenario only the first request will actually have to delete the database.
+    // Subsequent requests can immediately notify their completion.
+
+    if (m_databaseInfo) {
+        m_deleteBackingStoreInProgress = true;
+        m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::deleteBackingStore));
+    } else {
+        ASSERT(m_mostRecentDeletedDatabaseInfo);
+        didDeleteBackingStore();
+    }
 }
 
 void UniqueIDBDatabase::deleteBackingStore()
@@ -211,7 +219,6 @@ void UniqueIDBDatabase::didDeleteBackingStore()
     ASSERT(isMainThread());
     LOG(IndexedDB, "(main) UniqueIDBDatabase::didDeleteBackingStore");
 
-    ASSERT(m_databaseInfo);
     ASSERT(m_currentOpenDBRequest);
     ASSERT(m_currentOpenDBRequest->isDeleteRequest());
     ASSERT(!hasAnyPendingCallbacks());
@@ -219,9 +226,13 @@ void UniqueIDBDatabase::didDeleteBackingStore()
     ASSERT(m_pendingTransactions.isEmpty());
     ASSERT(m_openDatabaseConnections.isEmpty());
 
-    m_currentOpenDBRequest->notifyDidDeleteDatabase(*m_databaseInfo);
+    if (m_databaseInfo)
+        m_mostRecentDeletedDatabaseInfo = WTFMove(m_databaseInfo);
+
+    ASSERT(m_mostRecentDeletedDatabaseInfo);
+    m_currentOpenDBRequest->notifyDidDeleteDatabase(*m_mostRecentDeletedDatabaseInfo);
     m_currentOpenDBRequest = nullptr;
-    m_databaseInfo = nullptr;
+
     m_deletePending = false;
     m_deleteBackingStoreInProgress = false;
 
@@ -1007,9 +1018,6 @@ void UniqueIDBDatabase::connectionClosedFromClient(UniqueIDBDatabaseConnection&
 
     ASSERT(m_openDatabaseConnections.contains(&connection));
 
-    if (m_currentOpenDBRequest)
-        notifyCurrentRequestConnectionClosedOrFiredVersionChangeEvent(connection.identifier());
-
     Deque<RefPtr<UniqueIDBDatabaseTransaction>> pendingTransactions;
     while (!m_pendingTransactions.isEmpty()) {
         auto transaction = m_pendingTransactions.takeFirst();
@@ -1022,6 +1030,10 @@ void UniqueIDBDatabase::connectionClosedFromClient(UniqueIDBDatabaseConnection&
 
     RefPtr<UniqueIDBDatabaseConnection> refConnection(&connection);
     m_openDatabaseConnections.remove(&connection);
+
+    if (m_currentOpenDBRequest)
+        notifyCurrentRequestConnectionClosedOrFiredVersionChangeEvent(connection.identifier());
+
     if (connection.hasNonFinishedTransactions()) {
         m_closePendingDatabaseConnections.add(WTFMove(refConnection));
         return;
index fc7bc76bdd87e59b1ed03e3c88dc70f846a8dbc4..a3fec21bd639e67ba16634a5c3d83bdfd1048885 100644 (file)
@@ -193,6 +193,7 @@ private:
     bool m_isOpeningBackingStore { false };
     std::unique_ptr<IDBBackingStore> m_backingStore;
     std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
+    std::unique_ptr<IDBDatabaseInfo> m_mostRecentDeletedDatabaseInfo;
 
     HashMap<uint64_t, ErrorCallback> m_errorCallbacks;
     HashMap<uint64_t, KeyDataCallback> m_keyDataCallbacks;