Test features of IndexedDB's unique indices.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
dbname = "index-unique.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
db.createObjectStore('store')
store.createIndex('index', 'x', {unique: true})
setVersionCompleted():
transaction = db.transaction(['store'], 'readwrite')
transaction.objectStore('store').put({x: 1}, 'foo')
addMoreData():
transaction.objectStore('store').put({x: 1}, 'bar')
addMoreDataFailed():
event.preventDefault()
PASS event.target.error.name is 'ConstraintError'
transaction.objectStore('store').put({x: 0}, 'foo')
changeDataSuccess():
transaction.objectStore('store').index('index').openCursor(IDBKeyRange.lowerBound(1))
cursorSuccess():
PASS event.target.result is null
transaction.objectStore('store').index('index').openKeyCursor(IDBKeyRange.lowerBound(1))
keyCursorSuccess():
PASS event.target.result is null
transaction.objectStore('store').put({x: 1}, 'bar')
addMoreDataSucces():
transaction.objectStore('store').delete('bar')
deleteSuccess():
transaction.objectStore('store').put({x: 1}, 'baz')
finalAddSuccess():
transaction.objectStore('store').put({x: 1}, 'baz')
PASS successfullyParsed is true
TEST COMPLETE