blob: aa3788010bf7f70c4af2ca5619024974bb5f5a50 [file] [log] [blame]
Test openCursor/openKeyCursor with raw IDBKeys.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
objectStore = db.createObjectStore(objectStoreName);
First, add all our data to the object store.
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
Now create the indexes.
objectStore.createIndex(indexData[i].name, indexData[i].keyPath, indexData[i].options);
objectStore.createIndex(indexData[i].name, indexData[i].keyPath, indexData[i].options);
objectStore.createIndex(indexData[i].name, indexData[i].keyPath, indexData[i].options);
testObjectStore()
trans = db.transaction(objectStoreName, 'readwrite')
objectStore = trans.objectStore(objectStoreName)
request = objectStore.openCursor('237-23-7739')
PASS cursor.key is "237-23-7739"
PASS JSON.stringify(cursor.value) is JSON.stringify(objectStoreData[7].value)
PASS cursor.primaryKey is cursor.key
cursor.continue()
PASS cursor is null
trans = db.transaction(objectStoreName, 'readwrite')
objectStore = trans.objectStore(objectStoreName)
index = objectStore.index('weight')
request = index.openCursor(180)
PASS cursor.key is 180
PASS JSON.stringify(cursor.value) is JSON.stringify(objectStoreData[2].value)
PASS cursor.primaryKey is "237-23-7734"
cursor.continue()
PASS cursor.key is 180
PASS JSON.stringify(cursor.value) is JSON.stringify(objectStoreData[6].value)
PASS cursor.primaryKey is "237-23-7738"
cursor.continue()
PASS cursor.key is 180
PASS JSON.stringify(cursor.value) is JSON.stringify(objectStoreData[10].value)
PASS cursor.primaryKey is "237-23-7742"
cursor.continue()
PASS cursor is null
trans = db.transaction(objectStoreName, 'readwrite')
objectStore = trans.objectStore(objectStoreName)
index = objectStore.index('weight')
request = index.openKeyCursor(180)
PASS cursor.key is 180
PASS cursor.primaryKey is "237-23-7734"
cursor.continue()
PASS cursor.key is 180
PASS cursor.primaryKey is "237-23-7738"
cursor.continue()
PASS cursor.key is 180
PASS cursor.primaryKey is "237-23-7742"
cursor.continue()
PASS cursor is null
PASS successfullyParsed is true
TEST COMPLETE