1 Test openCursor/openKeyCursor with raw IDBKeys.
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "opencursor-key.html"
7 indexedDB.deleteDatabase(dbname)
9 objectStore = db.createObjectStore(objectStoreName);
10 First, add all our data to the object store.
11 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
12 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
13 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
14 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
15 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
16 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
17 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
18 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
19 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
20 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
21 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
22 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
23 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
24 Now create the indexes.
25 objectStore.createIndex(indexData[i].name, indexData[i].keyPath, indexData[i].options);
26 objectStore.createIndex(indexData[i].name, indexData[i].keyPath, indexData[i].options);
27 objectStore.createIndex(indexData[i].name, indexData[i].keyPath, indexData[i].options);
29 trans = db.transaction(objectStoreName, 'readwrite')
30 objectStore = trans.objectStore(objectStoreName)
31 request = objectStore.openCursor('237-23-7739')
32 PASS cursor.key is "237-23-7739"
33 PASS JSON.stringify(cursor.value) is JSON.stringify(objectStoreData[7].value)
34 PASS cursor.primaryKey is cursor.key
37 trans = db.transaction(objectStoreName, 'readwrite')
38 objectStore = trans.objectStore(objectStoreName)
39 index = objectStore.index('weight')
40 request = index.openCursor(180)
41 PASS cursor.key is 180
42 PASS JSON.stringify(cursor.value) is JSON.stringify(objectStoreData[2].value)
43 PASS cursor.primaryKey is "237-23-7734"
45 PASS cursor.key is 180
46 PASS JSON.stringify(cursor.value) is JSON.stringify(objectStoreData[6].value)
47 PASS cursor.primaryKey is "237-23-7738"
49 PASS cursor.key is 180
50 PASS JSON.stringify(cursor.value) is JSON.stringify(objectStoreData[10].value)
51 PASS cursor.primaryKey is "237-23-7742"
54 trans = db.transaction(objectStoreName, 'readwrite')
55 objectStore = trans.objectStore(objectStoreName)
56 index = objectStore.index('weight')
57 request = index.openKeyCursor(180)
58 PASS cursor.key is 180
59 PASS cursor.primaryKey is "237-23-7734"
61 PASS cursor.key is 180
62 PASS cursor.primaryKey is "237-23-7738"
64 PASS cursor.key is 180
65 PASS cursor.primaryKey is "237-23-7742"
68 PASS successfullyParsed is true