Modern IDB: Memory indexes aren't deleted when their owning memory object stores...
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jan 2016 00:06:05 +0000 (00:06 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jan 2016 00:06:05 +0000 (00:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152717

Reviewed by Alex Christensen.

Source/WebCore:

Test: storage/indexeddb/modern/memory-index-not-deleted-with-objectstore.html

* Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
(WebCore::IDBServer::MemoryBackingStoreTransaction::objectStoreDeleted):
* Modules/indexeddb/server/MemoryObjectStore.cpp:
(WebCore::IDBServer::MemoryObjectStore::deleteAllIndexes):
* Modules/indexeddb/server/MemoryObjectStore.h:

LayoutTests:

* storage/indexeddb/modern/memory-index-not-deleted-with-objectstore-expected.txt: Added.
* storage/indexeddb/modern/memory-index-not-deleted-with-objectstore.html: Added.
* storage/indexeddb/modern/resources/memory-index-not-deleted-with-objectstore.js: Added.

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

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/modern/memory-index-not-deleted-with-objectstore-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/memory-index-not-deleted-with-objectstore.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/resources/memory-index-not-deleted-with-objectstore.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp
Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp
Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h

index bd3bf17..6e83ab6 100644 (file)
@@ -1,3 +1,14 @@
+2016-01-04  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Memory indexes aren't deleted when their owning memory object stores are deleted.
+        https://bugs.webkit.org/show_bug.cgi?id=152717
+
+        Reviewed by Alex Christensen.
+
+        * storage/indexeddb/modern/memory-index-not-deleted-with-objectstore-expected.txt: Added.
+        * storage/indexeddb/modern/memory-index-not-deleted-with-objectstore.html: Added.
+        * storage/indexeddb/modern/resources/memory-index-not-deleted-with-objectstore.js: Added.
+
 2016-01-04  Sergio Villar Senin  <svillar@igalia.com>
 
         REGRESSION(r194143): Float width incorrectly calculated on Wikipedia
diff --git a/LayoutTests/storage/indexeddb/modern/memory-index-not-deleted-with-objectstore-expected.txt b/LayoutTests/storage/indexeddb/modern/memory-index-not-deleted-with-objectstore-expected.txt
new file mode 100644 (file)
index 0000000..510f6d0
--- /dev/null
@@ -0,0 +1,165 @@
+Makes sure that when an in-memory object store is deleted, any in-memory indexes it has are also deleted. If the test does not crash, it passes.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+dbname = "memory-index-not-deleted-with-objectstore.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+connection = event.target.result;
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+store = connection.createObjectStore('name');
+index = store.createIndex('name', 'foo');
+Deleted all object stores.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/modern/memory-index-not-deleted-with-objectstore.html b/LayoutTests/storage/indexeddb/modern/memory-index-not-deleted-with-objectstore.html
new file mode 100644 (file)
index 0000000..cc085cb
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script src="../resources/shared.js"></script>
+</head>
+<body>
+<script src="resources/memory-index-not-deleted-with-objectstore.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/storage/indexeddb/modern/resources/memory-index-not-deleted-with-objectstore.js b/LayoutTests/storage/indexeddb/modern/resources/memory-index-not-deleted-with-objectstore.js
new file mode 100644 (file)
index 0000000..d4984a8
--- /dev/null
@@ -0,0 +1,19 @@
+description("Makes sure that when an in-memory object store is deleted, any in-memory indexes it has are also deleted. If the test does not crash, it passes.");
+
+indexedDBTest(prepareDatabase, versionChangeDone);
+
+function prepareDatabase()
+{
+    evalAndLog("connection = event.target.result;");
+
+    for (var i = 0; i < 50; ++i) {
+        evalAndLog("store = connection.createObjectStore('name');");
+        evalAndLog("index = store.createIndex('name', 'foo');");
+        deleteAllObjectStores(connection);
+    }
+}
+
+function versionChangeDone()
+{
+    finishJSTest();
+}
index 2a9f870..1904d9d 100644 (file)
@@ -1,3 +1,18 @@
+2016-01-04  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Memory indexes aren't deleted when their owning memory object stores are deleted.
+        https://bugs.webkit.org/show_bug.cgi?id=152717
+
+        Reviewed by Alex Christensen.
+
+        Test: storage/indexeddb/modern/memory-index-not-deleted-with-objectstore.html
+
+        * Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
+        (WebCore::IDBServer::MemoryBackingStoreTransaction::objectStoreDeleted):
+        * Modules/indexeddb/server/MemoryObjectStore.cpp:
+        (WebCore::IDBServer::MemoryObjectStore::deleteAllIndexes):
+        * Modules/indexeddb/server/MemoryObjectStore.h:
+
 2016-01-04  Tim Horton  <timothy_horton@apple.com>
 
         Turn on gesture events when building for Yosemite
index 087c5da..8e0c767 100644 (file)
@@ -116,6 +116,8 @@ void MemoryBackingStoreTransaction::objectStoreDeleted(std::unique_ptr<MemoryObj
     ASSERT(m_objectStores.contains(objectStore.get()));
     m_objectStores.remove(objectStore.get());
 
+    objectStore->deleteAllIndexes(*this);
+
     auto addResult = m_deletedObjectStores.add(objectStore->info().name(), nullptr);
     if (addResult.isNewEntry)
         addResult.iterator->value = WTFMove(objectStore);
index a48ce8b..38ea578 100644 (file)
@@ -156,6 +156,18 @@ IDBError MemoryObjectStore::deleteIndex(MemoryBackingStoreTransaction& transacti
     return { };
 }
 
+void MemoryObjectStore::deleteAllIndexes(MemoryBackingStoreTransaction& transaction)
+{
+    Vector<String> indexNames;
+    indexNames.reserveInitialCapacity(m_indexesByName.size());
+
+    for (auto& name : m_indexesByName.keys())
+        indexNames.uncheckedAppend(name);
+
+    for (auto& name : indexNames)
+        deleteIndex(transaction, name);
+}
+
 bool MemoryObjectStore::containsRecord(const IDBKeyData& key)
 {
     if (!m_keyValueStore)
index b994660..8b6e1ab 100644 (file)
@@ -67,6 +67,7 @@ public:
 
     IDBError createIndex(MemoryBackingStoreTransaction&, const IDBIndexInfo&);
     IDBError deleteIndex(MemoryBackingStoreTransaction&, const String& indexName);
+    void deleteAllIndexes(MemoryBackingStoreTransaction&);
     void registerIndex(std::unique_ptr<MemoryIndex>&&);
 
     bool containsRecord(const IDBKeyData&);