1 Test IndexedDB index population.
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "index-population.html"
7 indexedDB.deleteDatabase(dbname)
9 transaction = event.target.transaction
10 store = db.createObjectStore('store1')
11 store.put({data: 'a', indexKey: 10}, 1)
12 store.put({data: 'b', indexKey: 20}, 2)
13 store.put({data: 'c', indexKey: 10}, 3)
14 store.put({data: 'd', indexKey: 20}, 4)
15 index = store.createIndex('index1', 'indexKey')
16 PASS index instanceof IDBIndex is true
17 PASS index.unique is false
18 request = index.count(IDBKeyRange.bound(-Infinity, Infinity))
19 PASS request.result is 4
23 request = indexedDB.open(dbname, 2)
26 transaction = request.transaction
27 store = db.createObjectStore('store2')
28 store.put({data: 'a', indexKey: 10}, 1)
29 store.put({data: 'b', indexKey: 20}, 2)
30 store.put({data: 'c', indexKey: 10}, 3)
31 store.put({data: 'd', indexKey: 20}, 4)
32 index2 = store.createIndex('index2', 'indexKey', { unique: true })
33 PASS index2 instanceof IDBIndex is true
34 PASS index2.unique is true
37 PASS db.objectStoreNames.length is 1
38 PASS db.objectStoreNames[0] is "store1"
39 PASS successfullyParsed is true