2011-12-02 18:31:40 +00:00
|
|
|
Test features of IndexedDB's multiEntry indices.
|
2011-12-01 05:22:26 +00:00
|
|
|
|
|
|
|
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
|
|
|
|
|
|
|
|
|
2012-03-14 21:20:56 +00:00
|
|
|
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
|
|
|
|
|
2012-11-14 21:52:49 +00:00
|
|
|
indexedDB.deleteDatabase(dbname)
|
|
|
|
indexedDB.open(dbname)
|
2011-12-01 05:22:26 +00:00
|
|
|
store = db.createObjectStore('store')
|
2011-12-02 18:31:40 +00:00
|
|
|
store.createIndex('index', 'x', {multiEntry: true})
|
2011-12-01 05:22:26 +00:00
|
|
|
store2 = db.createObjectStore('store-unique')
|
2011-12-02 18:31:40 +00:00
|
|
|
store2.createIndex('index-unique', 'x', {multiEntry: true, unique: true})
|
2011-12-01 05:22:26 +00:00
|
|
|
|
|
|
|
Populating stores (and indexes)
|
2012-05-07 19:12:00 +00:00
|
|
|
transaction = db.transaction(['store'], 'readwrite')
|
2011-12-01 05:22:26 +00:00
|
|
|
First try some keys that aren't what we're expecting
|
|
|
|
transaction.objectStore('store').put({x: [7, 8, 9], y: 'a'}, 'foo')
|
|
|
|
Now overwrite them with what we're expecting
|
|
|
|
transaction.objectStore('store').put({x: [1, 2, 3], y: 'a'}, 'foo')
|
|
|
|
transaction.objectStore('store').put({x: [4, 5, 6], y: 'b'}, 'bar')
|
2012-06-21 22:28:40 +00:00
|
|
|
transaction.objectStore('store').put({x: [7, 7, 8, 7], y: 'c'}, 'baz')
|
|
|
|
transaction.objectStore('store').put({x: [null, 9, 9], y: 'd'}, 'bloop')
|
2018-07-24 00:35:02 +00:00
|
|
|
transaction.objectStore('store').put({x: [1, [2, null]], y:'e'}, 'oh')
|
2011-12-01 05:22:26 +00:00
|
|
|
|
|
|
|
Verifying index: index
|
2012-05-07 19:12:00 +00:00
|
|
|
transaction = db.transaction(['store'], 'readonly')
|
2011-12-01 05:22:26 +00:00
|
|
|
transaction.objectStore('store').index('index').openCursor()
|
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 1
|
|
|
|
PASS cursor.primaryKey is "foo"
|
|
|
|
PASS cursor.value.y is "a"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2018-07-24 00:35:02 +00:00
|
|
|
PASS cursor.key is 1
|
|
|
|
PASS cursor.primaryKey is "oh"
|
|
|
|
PASS cursor.value.y is "e"
|
|
|
|
cursor.continue()
|
|
|
|
cursor = event.target.result
|
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 2
|
|
|
|
PASS cursor.primaryKey is "foo"
|
|
|
|
PASS cursor.value.y is "a"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 3
|
|
|
|
PASS cursor.primaryKey is "foo"
|
|
|
|
PASS cursor.value.y is "a"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 4
|
|
|
|
PASS cursor.primaryKey is "bar"
|
|
|
|
PASS cursor.value.y is "b"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 5
|
|
|
|
PASS cursor.primaryKey is "bar"
|
|
|
|
PASS cursor.value.y is "b"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 6
|
|
|
|
PASS cursor.primaryKey is "bar"
|
|
|
|
PASS cursor.value.y is "b"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
|
|
|
cursor = event.target.result
|
|
|
|
PASS ex is non-null.
|
|
|
|
PASS cursor.key is 7
|
|
|
|
PASS cursor.primaryKey is "baz"
|
|
|
|
PASS cursor.value.y is "c"
|
|
|
|
cursor.continue()
|
|
|
|
cursor = event.target.result
|
|
|
|
PASS ex is non-null.
|
|
|
|
PASS cursor.key is 8
|
|
|
|
PASS cursor.primaryKey is "baz"
|
|
|
|
PASS cursor.value.y is "c"
|
|
|
|
cursor.continue()
|
|
|
|
cursor = event.target.result
|
|
|
|
PASS ex is non-null.
|
|
|
|
PASS cursor.key is 9
|
|
|
|
PASS cursor.primaryKey is "bloop"
|
|
|
|
PASS cursor.value.y is "d"
|
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS expected.length is 0
|
IndexedDB: Migrate backend ObjectStore calls to use transaction id
https://bugs.webkit.org/show_bug.cgi?id=102741
Reviewed by Tony Chang.
Source/WebCore:
Fully migrate 8 core data calls (get, put, setIndexKeys, setIndexesReady,
openCursor, count, deleteRange, and clear) into IDBDatabaseBackendImpl,
combining common code from IDBObjectStoreBackendImpl and IDBIndexBackendImpl
in order to simplify the backend interface. These calls are now
implemented in terms of an int64_t-based transactionId rather than
an IDBTransactionBackendInterface, which simplifies the ownership model
between the frontend and the backend.
In addition, remove references to IDBObjectStoreBackend* from IDBIndex,
as it is no longer needed.
A few duplicate IDB_TRACE methods have been removed from wrapper methods
that call another method that already have IDB_TRACE's.
Finally, IDBCursorBackendImpl now no longer holds onto an
IDBObjectStoreBackendImpl*, so its destruction and member variables are
simplified, and reordered to match proper destruction order.
* Modules/indexeddb/IDBCursorBackendImpl.cpp: Reordered to account for proper destruction.
(WebCore::IDBCursorBackendImpl::IDBCursorBackendImpl):
(WebCore::IDBCursorBackendImpl::~IDBCursorBackendImpl):
(WebCore::IDBCursorBackendImpl::deleteFunction):
* Modules/indexeddb/IDBCursorBackendImpl.h:
(WebCore::IDBCursorBackendImpl::create):
(IDBCursorBackendImpl):
* Modules/indexeddb/IDBDatabase.h:
(WebCore::IDBDatabase::backend):
(IDBDatabase):
* Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
(GetOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::*RetrievalOperation
(WebCore::GetOperation::create):
(WebCore::GetOperation::GetOperation):
(WebCore):
(PutOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::*StorageOperation.
(WebCore::PutOperation::create):
(WebCore::PutOperation::PutOperation):
(SetIndexesReadyOperation): Moved from IDBObjectStoreBackendImpl::IndexesReadyOperation
(WebCore::SetIndexesReadyOperation::create):
(WebCore::SetIndexesReadyOperation::SetIndexesReadyOperation):
(OpenCursorOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::Open*CursorOperation
(WebCore::OpenCursorOperation::create):
(WebCore::OpenCursorOperation::OpenCursorOperation):
(CountOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::CountOperation
(WebCore::CountOperation::create):
(WebCore::CountOperation::CountOperation):
(DeleteRangeOperation): Moved from IDBObjectStoreBackendImpl::DeleteOperation
(WebCore::DeleteRangeOperation::create):
(WebCore::DeleteRangeOperation::DeleteRangeOperation):
(ClearOperation): Moved from IDBObjectStoreBackendImpl::ClearOperation
(WebCore::ClearOperation::create):
(WebCore::ClearOperation::ClearOperation):
(WebCore::IDBDatabaseBackendImpl::get): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::get*
(WebCore::GetOperation::perform):
(WebCore::IDBDatabaseBackendImpl::put): Moved from IDBObjectStoreBackendImpl::put
(WebCore::PutOperation::perform):
(WebCore::IDBDatabaseBackendImpl::setIndexKeys): Moved from IDBObjectStoreBackendImpl::setIndexKeys
(WebCore::IDBDatabaseBackendImpl::setIndexesReady):
(WebCore::SetIndexesReadyOperation::perform):
(WebCore::IDBDatabaseBackendImpl::openCursor):
(WebCore::IDBDatabaseBackendImpl::count):
(WebCore::CountOperation::perform):
(WebCore::IDBDatabaseBackendImpl::deleteRange):
(WebCore::DeleteRangeOperation::perform):
(WebCore::IDBDatabaseBackendImpl::clear):
(WebCore::ClearOperation::perform):
(WebCore::OpenCursorOperation::perform):
* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::IDBIndex):
(WebCore::IDBIndex::openCursor):
(WebCore::IDBIndex::count):
(WebCore::IDBIndex::openKeyCursor):
(WebCore::IDBIndex::get):
(WebCore::IDBIndex::getKey):
(WebCore::IDBIndex::backendDB):
(WebCore):
* Modules/indexeddb/IDBIndex.h:
(WebCore::IDBIndex::create):
(IDBIndex):
* Modules/indexeddb/IDBIndexBackendImpl.cpp:
(WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl):
* Modules/indexeddb/IDBIndexBackendImpl.h:
(WebCore::IDBIndexBackendImpl::create):
(WebCore::IDBIndexBackendImpl::openCursor):
(WebCore::IDBIndexBackendImpl::count):
(WebCore::IDBIndexBackendImpl::openKeyCursor):
(WebCore::IDBIndexBackendImpl::get):
(WebCore::IDBIndexBackendImpl::getKey):
(IDBIndexBackendImpl):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::get):
(WebCore::IDBObjectStore::put):
(WebCore::IDBObjectStore::deleteFunction):
(WebCore::IDBObjectStore::clear):
(WebCore):
(WebCore::IDBObjectStore::createIndex):
(WebCore::IDBObjectStore::index):
(WebCore::IDBObjectStore::openCursor):
(WebCore::IDBObjectStore::count):
(WebCore::IDBObjectStore::backendDB):
* Modules/indexeddb/IDBObjectStore.h:
(WebCore::IDBObjectStore::id):
(IDBObjectStore):
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::createIndex):
(WebCore::IDBObjectStoreBackendImpl::loadIndexes):
(WebCore::IDBObjectStoreBackendImpl::generateKey):
(WebCore::IDBObjectStoreBackendImpl::updateKeyGenerator):
* Modules/indexeddb/IDBObjectStoreBackendImpl.h:
(WebCore::IDBObjectStoreBackendImpl::get):
(WebCore::IDBObjectStoreBackendImpl::put):
(WebCore::IDBObjectStoreBackendImpl::deleteFunction):
(WebCore::IDBObjectStoreBackendImpl::clear):
(WebCore::IDBObjectStoreBackendImpl::setIndexKeys):
(WebCore::IDBObjectStoreBackendImpl::setIndexesReady):
(WebCore::IDBObjectStoreBackendImpl::openCursor):
(WebCore::IDBObjectStoreBackendImpl::count):
(IDBObjectStoreBackendImpl):
* Modules/indexeddb/IDBTransactionBackendImpl.h:
(WebCore::IDBTransactionBackendImpl::database):
(IDBTransactionBackendImpl):
Source/WebKit/chromium:
Fix a bug where an array was initialized with a large empty buffer,
clean up whitespace, and update to match signatures that changed
in WebCore.
* public/WebIDBDatabase.h:
(WebKit::WebIDBDatabase::clear):
* src/WebIDBDatabaseImpl.cpp:
(WebKit::WebIDBDatabaseImpl::put):
* src/WebIDBIndexImpl.cpp:
* tests/IDBDatabaseBackendTest.cpp:
LayoutTests:
Add additional count() tests for multi-entry indexes, not previously
covered.
* storage/indexeddb/index-multientry-expected.txt:
* storage/indexeddb/resources/index-multientry.js:
(.transaction.oncomplete):
(verifyCount.request.onsuccess.request.onsuccess):
(verifyCount.request.onsuccess):
(verifyCount):
Canonical link: https://commits.webkit.org/124370@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-01-05 20:42:38 +00:00
|
|
|
transaction = db.transaction(['store'])
|
|
|
|
transaction.objectStore('store').index('index')
|
|
|
|
index.count()
|
2018-07-24 00:35:02 +00:00
|
|
|
PASS event.target.result is 10
|
IndexedDB: Migrate backend ObjectStore calls to use transaction id
https://bugs.webkit.org/show_bug.cgi?id=102741
Reviewed by Tony Chang.
Source/WebCore:
Fully migrate 8 core data calls (get, put, setIndexKeys, setIndexesReady,
openCursor, count, deleteRange, and clear) into IDBDatabaseBackendImpl,
combining common code from IDBObjectStoreBackendImpl and IDBIndexBackendImpl
in order to simplify the backend interface. These calls are now
implemented in terms of an int64_t-based transactionId rather than
an IDBTransactionBackendInterface, which simplifies the ownership model
between the frontend and the backend.
In addition, remove references to IDBObjectStoreBackend* from IDBIndex,
as it is no longer needed.
A few duplicate IDB_TRACE methods have been removed from wrapper methods
that call another method that already have IDB_TRACE's.
Finally, IDBCursorBackendImpl now no longer holds onto an
IDBObjectStoreBackendImpl*, so its destruction and member variables are
simplified, and reordered to match proper destruction order.
* Modules/indexeddb/IDBCursorBackendImpl.cpp: Reordered to account for proper destruction.
(WebCore::IDBCursorBackendImpl::IDBCursorBackendImpl):
(WebCore::IDBCursorBackendImpl::~IDBCursorBackendImpl):
(WebCore::IDBCursorBackendImpl::deleteFunction):
* Modules/indexeddb/IDBCursorBackendImpl.h:
(WebCore::IDBCursorBackendImpl::create):
(IDBCursorBackendImpl):
* Modules/indexeddb/IDBDatabase.h:
(WebCore::IDBDatabase::backend):
(IDBDatabase):
* Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
(GetOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::*RetrievalOperation
(WebCore::GetOperation::create):
(WebCore::GetOperation::GetOperation):
(WebCore):
(PutOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::*StorageOperation.
(WebCore::PutOperation::create):
(WebCore::PutOperation::PutOperation):
(SetIndexesReadyOperation): Moved from IDBObjectStoreBackendImpl::IndexesReadyOperation
(WebCore::SetIndexesReadyOperation::create):
(WebCore::SetIndexesReadyOperation::SetIndexesReadyOperation):
(OpenCursorOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::Open*CursorOperation
(WebCore::OpenCursorOperation::create):
(WebCore::OpenCursorOperation::OpenCursorOperation):
(CountOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::CountOperation
(WebCore::CountOperation::create):
(WebCore::CountOperation::CountOperation):
(DeleteRangeOperation): Moved from IDBObjectStoreBackendImpl::DeleteOperation
(WebCore::DeleteRangeOperation::create):
(WebCore::DeleteRangeOperation::DeleteRangeOperation):
(ClearOperation): Moved from IDBObjectStoreBackendImpl::ClearOperation
(WebCore::ClearOperation::create):
(WebCore::ClearOperation::ClearOperation):
(WebCore::IDBDatabaseBackendImpl::get): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::get*
(WebCore::GetOperation::perform):
(WebCore::IDBDatabaseBackendImpl::put): Moved from IDBObjectStoreBackendImpl::put
(WebCore::PutOperation::perform):
(WebCore::IDBDatabaseBackendImpl::setIndexKeys): Moved from IDBObjectStoreBackendImpl::setIndexKeys
(WebCore::IDBDatabaseBackendImpl::setIndexesReady):
(WebCore::SetIndexesReadyOperation::perform):
(WebCore::IDBDatabaseBackendImpl::openCursor):
(WebCore::IDBDatabaseBackendImpl::count):
(WebCore::CountOperation::perform):
(WebCore::IDBDatabaseBackendImpl::deleteRange):
(WebCore::DeleteRangeOperation::perform):
(WebCore::IDBDatabaseBackendImpl::clear):
(WebCore::ClearOperation::perform):
(WebCore::OpenCursorOperation::perform):
* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::IDBIndex):
(WebCore::IDBIndex::openCursor):
(WebCore::IDBIndex::count):
(WebCore::IDBIndex::openKeyCursor):
(WebCore::IDBIndex::get):
(WebCore::IDBIndex::getKey):
(WebCore::IDBIndex::backendDB):
(WebCore):
* Modules/indexeddb/IDBIndex.h:
(WebCore::IDBIndex::create):
(IDBIndex):
* Modules/indexeddb/IDBIndexBackendImpl.cpp:
(WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl):
* Modules/indexeddb/IDBIndexBackendImpl.h:
(WebCore::IDBIndexBackendImpl::create):
(WebCore::IDBIndexBackendImpl::openCursor):
(WebCore::IDBIndexBackendImpl::count):
(WebCore::IDBIndexBackendImpl::openKeyCursor):
(WebCore::IDBIndexBackendImpl::get):
(WebCore::IDBIndexBackendImpl::getKey):
(IDBIndexBackendImpl):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::get):
(WebCore::IDBObjectStore::put):
(WebCore::IDBObjectStore::deleteFunction):
(WebCore::IDBObjectStore::clear):
(WebCore):
(WebCore::IDBObjectStore::createIndex):
(WebCore::IDBObjectStore::index):
(WebCore::IDBObjectStore::openCursor):
(WebCore::IDBObjectStore::count):
(WebCore::IDBObjectStore::backendDB):
* Modules/indexeddb/IDBObjectStore.h:
(WebCore::IDBObjectStore::id):
(IDBObjectStore):
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::createIndex):
(WebCore::IDBObjectStoreBackendImpl::loadIndexes):
(WebCore::IDBObjectStoreBackendImpl::generateKey):
(WebCore::IDBObjectStoreBackendImpl::updateKeyGenerator):
* Modules/indexeddb/IDBObjectStoreBackendImpl.h:
(WebCore::IDBObjectStoreBackendImpl::get):
(WebCore::IDBObjectStoreBackendImpl::put):
(WebCore::IDBObjectStoreBackendImpl::deleteFunction):
(WebCore::IDBObjectStoreBackendImpl::clear):
(WebCore::IDBObjectStoreBackendImpl::setIndexKeys):
(WebCore::IDBObjectStoreBackendImpl::setIndexesReady):
(WebCore::IDBObjectStoreBackendImpl::openCursor):
(WebCore::IDBObjectStoreBackendImpl::count):
(IDBObjectStoreBackendImpl):
* Modules/indexeddb/IDBTransactionBackendImpl.h:
(WebCore::IDBTransactionBackendImpl::database):
(IDBTransactionBackendImpl):
Source/WebKit/chromium:
Fix a bug where an array was initialized with a large empty buffer,
clean up whitespace, and update to match signatures that changed
in WebCore.
* public/WebIDBDatabase.h:
(WebKit::WebIDBDatabase::clear):
* src/WebIDBDatabaseImpl.cpp:
(WebKit::WebIDBDatabaseImpl::put):
* src/WebIDBIndexImpl.cpp:
* tests/IDBDatabaseBackendTest.cpp:
LayoutTests:
Add additional count() tests for multi-entry indexes, not previously
covered.
* storage/indexeddb/index-multientry-expected.txt:
* storage/indexeddb/resources/index-multientry.js:
(.transaction.oncomplete):
(verifyCount.request.onsuccess.request.onsuccess):
(verifyCount.request.onsuccess):
(verifyCount):
Canonical link: https://commits.webkit.org/124370@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-01-05 20:42:38 +00:00
|
|
|
index.count(7)
|
|
|
|
PASS event.target.result is 1
|
2011-12-01 05:22:26 +00:00
|
|
|
|
2011-12-02 18:31:40 +00:00
|
|
|
Verifying unique constraint on multiEntry index
|
2012-05-07 19:12:00 +00:00
|
|
|
transaction = db.transaction(['store-unique'], 'readwrite')
|
2011-12-01 05:22:26 +00:00
|
|
|
transaction.objectStore('store-unique').put({x: [1, 2, 3], y: 'a'}, 'foo')
|
|
|
|
success!
|
|
|
|
Replace an existing record - this should work
|
|
|
|
transaction.objectStore('store-unique').put({x: [1, 2, 7], y: 'a'}, 'foo')
|
|
|
|
success!
|
|
|
|
This should fail the uniqueness constraint on the index, and fail:
|
|
|
|
transaction.objectStore('store-unique').put({x: [5, 2], y: 'c'}, 'should fail')
|
2012-08-16 00:50:52 +00:00
|
|
|
Request failed, as expected (ConstraintError)
|
2011-12-01 05:22:26 +00:00
|
|
|
Transaction aborted as expected
|
|
|
|
|
|
|
|
Create an index on a populated store
|
2012-11-14 21:52:49 +00:00
|
|
|
db.close()
|
|
|
|
indexedDB.open(dbname, 2)
|
|
|
|
db = event.target.result
|
|
|
|
trans = event.target.transaction
|
2011-12-01 05:22:26 +00:00
|
|
|
store = trans.objectStore('store')
|
2011-12-02 18:31:40 +00:00
|
|
|
store.createIndex('index-new', 'x', {multiEntry: true})
|
2011-12-01 05:22:26 +00:00
|
|
|
|
|
|
|
Verifying index: index-new
|
2012-05-07 19:12:00 +00:00
|
|
|
transaction = db.transaction(['store'], 'readonly')
|
2011-12-01 05:22:26 +00:00
|
|
|
transaction.objectStore('store').index('index-new').openCursor()
|
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 1
|
|
|
|
PASS cursor.primaryKey is "foo"
|
|
|
|
PASS cursor.value.y is "a"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2018-07-24 00:35:02 +00:00
|
|
|
PASS cursor.key is 1
|
|
|
|
PASS cursor.primaryKey is "oh"
|
|
|
|
PASS cursor.value.y is "e"
|
|
|
|
cursor.continue()
|
|
|
|
cursor = event.target.result
|
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 2
|
|
|
|
PASS cursor.primaryKey is "foo"
|
|
|
|
PASS cursor.value.y is "a"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 3
|
|
|
|
PASS cursor.primaryKey is "foo"
|
|
|
|
PASS cursor.value.y is "a"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 4
|
|
|
|
PASS cursor.primaryKey is "bar"
|
|
|
|
PASS cursor.value.y is "b"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 5
|
|
|
|
PASS cursor.primaryKey is "bar"
|
|
|
|
PASS cursor.value.y is "b"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS ex is non-null.
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS cursor.key is 6
|
|
|
|
PASS cursor.primaryKey is "bar"
|
|
|
|
PASS cursor.value.y is "b"
|
2012-06-21 22:28:40 +00:00
|
|
|
cursor.continue()
|
|
|
|
cursor = event.target.result
|
|
|
|
PASS ex is non-null.
|
|
|
|
PASS cursor.key is 7
|
|
|
|
PASS cursor.primaryKey is "baz"
|
|
|
|
PASS cursor.value.y is "c"
|
|
|
|
cursor.continue()
|
|
|
|
cursor = event.target.result
|
|
|
|
PASS ex is non-null.
|
|
|
|
PASS cursor.key is 8
|
|
|
|
PASS cursor.primaryKey is "baz"
|
|
|
|
PASS cursor.value.y is "c"
|
|
|
|
cursor.continue()
|
|
|
|
cursor = event.target.result
|
|
|
|
PASS ex is non-null.
|
|
|
|
PASS cursor.key is 9
|
|
|
|
PASS cursor.primaryKey is "bloop"
|
|
|
|
PASS cursor.value.y is "d"
|
|
|
|
cursor.continue()
|
2011-12-01 05:22:26 +00:00
|
|
|
cursor = event.target.result
|
2012-05-19 23:36:46 +00:00
|
|
|
PASS expected.length is 0
|
IndexedDB: Migrate backend ObjectStore calls to use transaction id
https://bugs.webkit.org/show_bug.cgi?id=102741
Reviewed by Tony Chang.
Source/WebCore:
Fully migrate 8 core data calls (get, put, setIndexKeys, setIndexesReady,
openCursor, count, deleteRange, and clear) into IDBDatabaseBackendImpl,
combining common code from IDBObjectStoreBackendImpl and IDBIndexBackendImpl
in order to simplify the backend interface. These calls are now
implemented in terms of an int64_t-based transactionId rather than
an IDBTransactionBackendInterface, which simplifies the ownership model
between the frontend and the backend.
In addition, remove references to IDBObjectStoreBackend* from IDBIndex,
as it is no longer needed.
A few duplicate IDB_TRACE methods have been removed from wrapper methods
that call another method that already have IDB_TRACE's.
Finally, IDBCursorBackendImpl now no longer holds onto an
IDBObjectStoreBackendImpl*, so its destruction and member variables are
simplified, and reordered to match proper destruction order.
* Modules/indexeddb/IDBCursorBackendImpl.cpp: Reordered to account for proper destruction.
(WebCore::IDBCursorBackendImpl::IDBCursorBackendImpl):
(WebCore::IDBCursorBackendImpl::~IDBCursorBackendImpl):
(WebCore::IDBCursorBackendImpl::deleteFunction):
* Modules/indexeddb/IDBCursorBackendImpl.h:
(WebCore::IDBCursorBackendImpl::create):
(IDBCursorBackendImpl):
* Modules/indexeddb/IDBDatabase.h:
(WebCore::IDBDatabase::backend):
(IDBDatabase):
* Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
(GetOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::*RetrievalOperation
(WebCore::GetOperation::create):
(WebCore::GetOperation::GetOperation):
(WebCore):
(PutOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::*StorageOperation.
(WebCore::PutOperation::create):
(WebCore::PutOperation::PutOperation):
(SetIndexesReadyOperation): Moved from IDBObjectStoreBackendImpl::IndexesReadyOperation
(WebCore::SetIndexesReadyOperation::create):
(WebCore::SetIndexesReadyOperation::SetIndexesReadyOperation):
(OpenCursorOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::Open*CursorOperation
(WebCore::OpenCursorOperation::create):
(WebCore::OpenCursorOperation::OpenCursorOperation):
(CountOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::CountOperation
(WebCore::CountOperation::create):
(WebCore::CountOperation::CountOperation):
(DeleteRangeOperation): Moved from IDBObjectStoreBackendImpl::DeleteOperation
(WebCore::DeleteRangeOperation::create):
(WebCore::DeleteRangeOperation::DeleteRangeOperation):
(ClearOperation): Moved from IDBObjectStoreBackendImpl::ClearOperation
(WebCore::ClearOperation::create):
(WebCore::ClearOperation::ClearOperation):
(WebCore::IDBDatabaseBackendImpl::get): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::get*
(WebCore::GetOperation::perform):
(WebCore::IDBDatabaseBackendImpl::put): Moved from IDBObjectStoreBackendImpl::put
(WebCore::PutOperation::perform):
(WebCore::IDBDatabaseBackendImpl::setIndexKeys): Moved from IDBObjectStoreBackendImpl::setIndexKeys
(WebCore::IDBDatabaseBackendImpl::setIndexesReady):
(WebCore::SetIndexesReadyOperation::perform):
(WebCore::IDBDatabaseBackendImpl::openCursor):
(WebCore::IDBDatabaseBackendImpl::count):
(WebCore::CountOperation::perform):
(WebCore::IDBDatabaseBackendImpl::deleteRange):
(WebCore::DeleteRangeOperation::perform):
(WebCore::IDBDatabaseBackendImpl::clear):
(WebCore::ClearOperation::perform):
(WebCore::OpenCursorOperation::perform):
* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::IDBIndex):
(WebCore::IDBIndex::openCursor):
(WebCore::IDBIndex::count):
(WebCore::IDBIndex::openKeyCursor):
(WebCore::IDBIndex::get):
(WebCore::IDBIndex::getKey):
(WebCore::IDBIndex::backendDB):
(WebCore):
* Modules/indexeddb/IDBIndex.h:
(WebCore::IDBIndex::create):
(IDBIndex):
* Modules/indexeddb/IDBIndexBackendImpl.cpp:
(WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl):
* Modules/indexeddb/IDBIndexBackendImpl.h:
(WebCore::IDBIndexBackendImpl::create):
(WebCore::IDBIndexBackendImpl::openCursor):
(WebCore::IDBIndexBackendImpl::count):
(WebCore::IDBIndexBackendImpl::openKeyCursor):
(WebCore::IDBIndexBackendImpl::get):
(WebCore::IDBIndexBackendImpl::getKey):
(IDBIndexBackendImpl):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::get):
(WebCore::IDBObjectStore::put):
(WebCore::IDBObjectStore::deleteFunction):
(WebCore::IDBObjectStore::clear):
(WebCore):
(WebCore::IDBObjectStore::createIndex):
(WebCore::IDBObjectStore::index):
(WebCore::IDBObjectStore::openCursor):
(WebCore::IDBObjectStore::count):
(WebCore::IDBObjectStore::backendDB):
* Modules/indexeddb/IDBObjectStore.h:
(WebCore::IDBObjectStore::id):
(IDBObjectStore):
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::createIndex):
(WebCore::IDBObjectStoreBackendImpl::loadIndexes):
(WebCore::IDBObjectStoreBackendImpl::generateKey):
(WebCore::IDBObjectStoreBackendImpl::updateKeyGenerator):
* Modules/indexeddb/IDBObjectStoreBackendImpl.h:
(WebCore::IDBObjectStoreBackendImpl::get):
(WebCore::IDBObjectStoreBackendImpl::put):
(WebCore::IDBObjectStoreBackendImpl::deleteFunction):
(WebCore::IDBObjectStoreBackendImpl::clear):
(WebCore::IDBObjectStoreBackendImpl::setIndexKeys):
(WebCore::IDBObjectStoreBackendImpl::setIndexesReady):
(WebCore::IDBObjectStoreBackendImpl::openCursor):
(WebCore::IDBObjectStoreBackendImpl::count):
(IDBObjectStoreBackendImpl):
* Modules/indexeddb/IDBTransactionBackendImpl.h:
(WebCore::IDBTransactionBackendImpl::database):
(IDBTransactionBackendImpl):
Source/WebKit/chromium:
Fix a bug where an array was initialized with a large empty buffer,
clean up whitespace, and update to match signatures that changed
in WebCore.
* public/WebIDBDatabase.h:
(WebKit::WebIDBDatabase::clear):
* src/WebIDBDatabaseImpl.cpp:
(WebKit::WebIDBDatabaseImpl::put):
* src/WebIDBIndexImpl.cpp:
* tests/IDBDatabaseBackendTest.cpp:
LayoutTests:
Add additional count() tests for multi-entry indexes, not previously
covered.
* storage/indexeddb/index-multientry-expected.txt:
* storage/indexeddb/resources/index-multientry.js:
(.transaction.oncomplete):
(verifyCount.request.onsuccess.request.onsuccess):
(verifyCount.request.onsuccess):
(verifyCount):
Canonical link: https://commits.webkit.org/124370@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-01-05 20:42:38 +00:00
|
|
|
transaction = db.transaction(['store'])
|
|
|
|
transaction.objectStore('store').index('index')
|
|
|
|
index.count()
|
2018-07-24 00:35:02 +00:00
|
|
|
PASS event.target.result is 10
|
IndexedDB: Migrate backend ObjectStore calls to use transaction id
https://bugs.webkit.org/show_bug.cgi?id=102741
Reviewed by Tony Chang.
Source/WebCore:
Fully migrate 8 core data calls (get, put, setIndexKeys, setIndexesReady,
openCursor, count, deleteRange, and clear) into IDBDatabaseBackendImpl,
combining common code from IDBObjectStoreBackendImpl and IDBIndexBackendImpl
in order to simplify the backend interface. These calls are now
implemented in terms of an int64_t-based transactionId rather than
an IDBTransactionBackendInterface, which simplifies the ownership model
between the frontend and the backend.
In addition, remove references to IDBObjectStoreBackend* from IDBIndex,
as it is no longer needed.
A few duplicate IDB_TRACE methods have been removed from wrapper methods
that call another method that already have IDB_TRACE's.
Finally, IDBCursorBackendImpl now no longer holds onto an
IDBObjectStoreBackendImpl*, so its destruction and member variables are
simplified, and reordered to match proper destruction order.
* Modules/indexeddb/IDBCursorBackendImpl.cpp: Reordered to account for proper destruction.
(WebCore::IDBCursorBackendImpl::IDBCursorBackendImpl):
(WebCore::IDBCursorBackendImpl::~IDBCursorBackendImpl):
(WebCore::IDBCursorBackendImpl::deleteFunction):
* Modules/indexeddb/IDBCursorBackendImpl.h:
(WebCore::IDBCursorBackendImpl::create):
(IDBCursorBackendImpl):
* Modules/indexeddb/IDBDatabase.h:
(WebCore::IDBDatabase::backend):
(IDBDatabase):
* Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
(GetOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::*RetrievalOperation
(WebCore::GetOperation::create):
(WebCore::GetOperation::GetOperation):
(WebCore):
(PutOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::*StorageOperation.
(WebCore::PutOperation::create):
(WebCore::PutOperation::PutOperation):
(SetIndexesReadyOperation): Moved from IDBObjectStoreBackendImpl::IndexesReadyOperation
(WebCore::SetIndexesReadyOperation::create):
(WebCore::SetIndexesReadyOperation::SetIndexesReadyOperation):
(OpenCursorOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::Open*CursorOperation
(WebCore::OpenCursorOperation::create):
(WebCore::OpenCursorOperation::OpenCursorOperation):
(CountOperation): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::CountOperation
(WebCore::CountOperation::create):
(WebCore::CountOperation::CountOperation):
(DeleteRangeOperation): Moved from IDBObjectStoreBackendImpl::DeleteOperation
(WebCore::DeleteRangeOperation::create):
(WebCore::DeleteRangeOperation::DeleteRangeOperation):
(ClearOperation): Moved from IDBObjectStoreBackendImpl::ClearOperation
(WebCore::ClearOperation::create):
(WebCore::ClearOperation::ClearOperation):
(WebCore::IDBDatabaseBackendImpl::get): Combined from IDBObjectStoreBackendImpl/IDBIndexBackendImpl::get*
(WebCore::GetOperation::perform):
(WebCore::IDBDatabaseBackendImpl::put): Moved from IDBObjectStoreBackendImpl::put
(WebCore::PutOperation::perform):
(WebCore::IDBDatabaseBackendImpl::setIndexKeys): Moved from IDBObjectStoreBackendImpl::setIndexKeys
(WebCore::IDBDatabaseBackendImpl::setIndexesReady):
(WebCore::SetIndexesReadyOperation::perform):
(WebCore::IDBDatabaseBackendImpl::openCursor):
(WebCore::IDBDatabaseBackendImpl::count):
(WebCore::CountOperation::perform):
(WebCore::IDBDatabaseBackendImpl::deleteRange):
(WebCore::DeleteRangeOperation::perform):
(WebCore::IDBDatabaseBackendImpl::clear):
(WebCore::ClearOperation::perform):
(WebCore::OpenCursorOperation::perform):
* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::IDBIndex):
(WebCore::IDBIndex::openCursor):
(WebCore::IDBIndex::count):
(WebCore::IDBIndex::openKeyCursor):
(WebCore::IDBIndex::get):
(WebCore::IDBIndex::getKey):
(WebCore::IDBIndex::backendDB):
(WebCore):
* Modules/indexeddb/IDBIndex.h:
(WebCore::IDBIndex::create):
(IDBIndex):
* Modules/indexeddb/IDBIndexBackendImpl.cpp:
(WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl):
* Modules/indexeddb/IDBIndexBackendImpl.h:
(WebCore::IDBIndexBackendImpl::create):
(WebCore::IDBIndexBackendImpl::openCursor):
(WebCore::IDBIndexBackendImpl::count):
(WebCore::IDBIndexBackendImpl::openKeyCursor):
(WebCore::IDBIndexBackendImpl::get):
(WebCore::IDBIndexBackendImpl::getKey):
(IDBIndexBackendImpl):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::get):
(WebCore::IDBObjectStore::put):
(WebCore::IDBObjectStore::deleteFunction):
(WebCore::IDBObjectStore::clear):
(WebCore):
(WebCore::IDBObjectStore::createIndex):
(WebCore::IDBObjectStore::index):
(WebCore::IDBObjectStore::openCursor):
(WebCore::IDBObjectStore::count):
(WebCore::IDBObjectStore::backendDB):
* Modules/indexeddb/IDBObjectStore.h:
(WebCore::IDBObjectStore::id):
(IDBObjectStore):
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::createIndex):
(WebCore::IDBObjectStoreBackendImpl::loadIndexes):
(WebCore::IDBObjectStoreBackendImpl::generateKey):
(WebCore::IDBObjectStoreBackendImpl::updateKeyGenerator):
* Modules/indexeddb/IDBObjectStoreBackendImpl.h:
(WebCore::IDBObjectStoreBackendImpl::get):
(WebCore::IDBObjectStoreBackendImpl::put):
(WebCore::IDBObjectStoreBackendImpl::deleteFunction):
(WebCore::IDBObjectStoreBackendImpl::clear):
(WebCore::IDBObjectStoreBackendImpl::setIndexKeys):
(WebCore::IDBObjectStoreBackendImpl::setIndexesReady):
(WebCore::IDBObjectStoreBackendImpl::openCursor):
(WebCore::IDBObjectStoreBackendImpl::count):
(IDBObjectStoreBackendImpl):
* Modules/indexeddb/IDBTransactionBackendImpl.h:
(WebCore::IDBTransactionBackendImpl::database):
(IDBTransactionBackendImpl):
Source/WebKit/chromium:
Fix a bug where an array was initialized with a large empty buffer,
clean up whitespace, and update to match signatures that changed
in WebCore.
* public/WebIDBDatabase.h:
(WebKit::WebIDBDatabase::clear):
* src/WebIDBDatabaseImpl.cpp:
(WebKit::WebIDBDatabaseImpl::put):
* src/WebIDBIndexImpl.cpp:
* tests/IDBDatabaseBackendTest.cpp:
LayoutTests:
Add additional count() tests for multi-entry indexes, not previously
covered.
* storage/indexeddb/index-multientry-expected.txt:
* storage/indexeddb/resources/index-multientry.js:
(.transaction.oncomplete):
(verifyCount.request.onsuccess.request.onsuccess):
(verifyCount.request.onsuccess):
(verifyCount):
Canonical link: https://commits.webkit.org/124370@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-01-05 20:42:38 +00:00
|
|
|
index.count(7)
|
|
|
|
PASS event.target.result is 1
|
2011-12-01 05:22:26 +00:00
|
|
|
PASS successfullyParsed is true
|
|
|
|
|
|
|
|
TEST COMPLETE
|
|
|
|
|