1 Test features of IndexedDB's unique indices.
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "index-unique.html"
7 indexedDB.deleteDatabase(dbname)
9 db.createObjectStore('store')
10 store.createIndex('index', 'x', {unique: true})
11 setVersionCompleted():
12 transaction = db.transaction(['store'], 'readwrite')
13 transaction.objectStore('store').put({x: 1}, 'foo')
15 transaction.objectStore('store').put({x: 1}, 'bar')
17 event.preventDefault()
18 PASS event.target.error.name is 'ConstraintError'
19 transaction.objectStore('store').put({x: 0}, 'foo')
21 transaction.objectStore('store').index('index').openCursor(IDBKeyRange.lowerBound(1))
23 PASS event.target.result is null
24 transaction.objectStore('store').index('index').openKeyCursor(IDBKeyRange.lowerBound(1))
26 PASS event.target.result is null
27 transaction.objectStore('store').put({x: 1}, 'bar')
29 transaction.objectStore('store').delete('bar')
31 transaction.objectStore('store').put({x: 1}, 'baz')
33 transaction.objectStore('store').put({x: 1}, 'baz')
34 PASS successfullyParsed is true