blob: 8a6277b8b3dd74c97deb14460b1d5384493481d1 [file] [log] [blame]
Test IndexedDB cursor.advance().
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)
prepareDatabase():
objectStore = db.createObjectStore(objectStoreName);
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);
trans = db.transaction(objectStoreName, 'readwrite')
objectStore = trans.objectStore(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);
testSimple()
trans = db.transaction(objectStoreName)
store = trans.objectStore(objectStoreName)
request = store.openCursor()
cursor.advance(1)
PASS expected is "{\"key\":\"237-23-7733\",\"value\":{\"name\":\"Ann\",\"height\":52,\"weight\":110},\"primaryKey\":\"237-23-7733\"}"
testContinueThenAdvance()
trans = db.transaction(objectStoreName)
store = trans.objectStore(objectStoreName)
request = store.openCursor()
cursor.continue();
cursor.continue();
cursor.continue();
cursor.advance(1)
PASS expected is "{\"key\":\"237-23-7736\",\"value\":{\"name\":\"Joe\",\"height\":65,\"weight\":150},\"primaryKey\":\"237-23-7736\"}"
testAdvanceMultiple()
trans = db.transaction(objectStoreName)
store = trans.objectStore(objectStoreName)
request = store.openCursor()
cursor.advance(3)
PASS expected is "{\"key\":\"237-23-7735\",\"value\":{\"name\":\"Sue\",\"height\":58,\"weight\":130},\"primaryKey\":\"237-23-7735\"}"
testAdvanceIndex()
trans = db.transaction(objectStoreName)
store = trans.objectStore(objectStoreName)
request = store.openCursor()
cursor.advance(3)
PASS expected is "{\"key\":\"Jef\",\"value\":{\"name\":\"Jef\",\"height\":65,\"weight\":120},\"primaryKey\":\"237-23-7739\"}"
testAdvanceIndexNoDupe()
trans = db.transaction(objectStoreName)
store = trans.objectStore(objectStoreName)
request = store.openCursor(null, 'nextunique')
cursor.advance(3)
PASS expected is "{\"key\":130,\"value\":{\"name\":\"Sue\",\"height\":58,\"weight\":130},\"primaryKey\":\"237-23-7735\"}"
testAdvanceIndexPrev()
trans = db.transaction(objectStoreName)
store = trans.objectStore(objectStoreName)
request = store.openCursor(null, 'prev')
cursor.advance(3)
PASS expected is "{\"key\":150,\"value\":{\"name\":\"Joe\",\"height\":65,\"weight\":150},\"primaryKey\":\"237-23-7736\"}"
testAdvanceIndexPrevNoDupe()
trans = db.transaction(objectStoreName)
store = trans.objectStore(objectStoreName)
request = store.openCursor(null, 'prevunique')
cursor.advance(3)
PASS expected is "{\"key\":120,\"value\":{\"name\":\"Bob\",\"height\":60,\"weight\":120},\"primaryKey\":\"237-23-7732\"}"
testAdvanceToEnd()
trans = db.transaction(objectStoreName)
store = trans.objectStore(objectStoreName)
request = store.openCursor()
cursor.advance(100)
PASS expected is "null"
testPrefetchInRange()
trans = db.transaction(objectStoreName)
objectStore = trans.objectStore(objectStoreName)
request = objectStore.openCursor()
prefetch():
PASS expected is "{\"key\":\"237-23-7732\",\"value\":{\"name\":\"Bob\",\"height\":60,\"weight\":120},\"primaryKey\":\"237-23-7732\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7733\",\"value\":{\"name\":\"Ann\",\"height\":52,\"weight\":110},\"primaryKey\":\"237-23-7733\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7734\",\"value\":{\"name\":\"Ron\",\"height\":73,\"weight\":180},\"primaryKey\":\"237-23-7734\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7735\",\"value\":{\"name\":\"Sue\",\"height\":58,\"weight\":130},\"primaryKey\":\"237-23-7735\"}"
cursor.advance(2)
prefetch():
PASS expected is "{\"key\":\"237-23-7737\",\"value\":{\"name\":\"Pat\",\"height\":65,\"weight\":100},\"primaryKey\":\"237-23-7737\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7738\",\"value\":{\"name\":\"Leo\",\"height\":65,\"weight\":180},\"primaryKey\":\"237-23-7738\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7739\",\"value\":{\"name\":\"Jef\",\"height\":65,\"weight\":120},\"primaryKey\":\"237-23-7739\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7740\",\"value\":{\"name\":\"Sam\",\"height\":71,\"weight\":110},\"primaryKey\":\"237-23-7740\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7741\",\"value\":{\"name\":\"Bug\",\"height\":63,\"weight\":100},\"primaryKey\":\"237-23-7741\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7742\",\"value\":{\"name\":\"Tub\",\"height\":69,\"weight\":180},\"primaryKey\":\"237-23-7742\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7743\",\"value\":{\"name\":\"Rug\",\"height\":77,\"weight\":120},\"primaryKey\":\"237-23-7743\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7744\",\"value\":{\"name\":\"Pug\",\"height\":66,\"weight\":110},\"primaryKey\":\"237-23-7744\"}"
cursor.continue()
prefetch():
testPrefetchOutOfRange()
trans = db.transaction(objectStoreName)
objectStore = trans.objectStore(objectStoreName)
request = objectStore.openCursor()
prefetch():
PASS expected is "{\"key\":\"237-23-7732\",\"value\":{\"name\":\"Bob\",\"height\":60,\"weight\":120},\"primaryKey\":\"237-23-7732\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7733\",\"value\":{\"name\":\"Ann\",\"height\":52,\"weight\":110},\"primaryKey\":\"237-23-7733\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7734\",\"value\":{\"name\":\"Ron\",\"height\":73,\"weight\":180},\"primaryKey\":\"237-23-7734\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7735\",\"value\":{\"name\":\"Sue\",\"height\":58,\"weight\":130},\"primaryKey\":\"237-23-7735\"}"
cursor.advance(7)
prefetch():
PASS expected is "{\"key\":\"237-23-7742\",\"value\":{\"name\":\"Tub\",\"height\":69,\"weight\":180},\"primaryKey\":\"237-23-7742\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7743\",\"value\":{\"name\":\"Rug\",\"height\":77,\"weight\":120},\"primaryKey\":\"237-23-7743\"}"
cursor.continue()
prefetch():
PASS expected is "{\"key\":\"237-23-7744\",\"value\":{\"name\":\"Pug\",\"height\":66,\"weight\":110},\"primaryKey\":\"237-23-7744\"}"
cursor.continue()
prefetch():
testBadAdvance()
trans = db.transaction(objectStoreName, 'readwrite')
objectStore = trans.objectStore(objectStoreName)
request = objectStore.openCursor()
advanceBadly():
Expecting TypeError exception from cursor.advance(0)
PASS Exception was thrown.
PASS cursor.advance(0) threw TypeError: Failed to execute 'advance' on 'IDBCursor': A count argument with value 0 (zero) was supplied, must be greater than 0.
Expecting TypeError exception from cursor.advance(-1)
PASS Exception was thrown.
PASS cursor.advance(-1) threw TypeError: Value -1 is outside the range [0, 4294967295]
Expecting TypeError exception from cursor.advance(0x100000000)
PASS Exception was thrown.
PASS cursor.advance(0x100000000) threw TypeError: Value 4294967296 is outside the range [0, 4294967295]
Expecting TypeError exception from cursor.advance(0x20000000000000)
PASS Exception was thrown.
PASS cursor.advance(0x20000000000000) threw TypeError: Value 9007199254740992 is outside the range [0, 4294967295]
testEdges():
trans = db.transaction(objectStoreName, 'readonly')
objectStore = trans.objectStore(objectStoreName)
request = objectStore.openCursor()
onSuccess():
cursor = event.target.result
PASS cursor is non-null.
cursor.advance(0xffffffff)
onSuccess():
cursor = event.target.result
PASS cursor is null
testDelete()
trans = db.transaction(objectStoreName, 'readwrite')
objectStore = trans.objectStore(objectStoreName)
request = objectStore.openCursor()
deleteSecond():
PASS expected is "{\"key\":\"237-23-7732\",\"value\":{\"name\":\"Bob\",\"height\":60,\"weight\":120},\"primaryKey\":\"237-23-7732\"}"
cursor.advance(1)
deleteSecond():
PASS expected is "{\"key\":\"237-23-7733\",\"value\":{\"name\":\"Ann\",\"height\":52,\"weight\":110},\"primaryKey\":\"237-23-7733\"}"
cursor.advance(1)
deleteSecond():
PASS expected is "{\"key\":\"237-23-7734\",\"value\":{\"name\":\"Ron\",\"height\":73,\"weight\":180},\"primaryKey\":\"237-23-7734\"}"
cursor.delete()
deleteSecond():
PASS expected is "{\"key\":\"237-23-7738\",\"value\":{\"name\":\"Leo\",\"height\":65,\"weight\":180},\"primaryKey\":\"237-23-7738\"}"
cursor.advance(1)
deleteSecond():
PASS expected is "{\"key\":\"237-23-7739\",\"value\":{\"name\":\"Jef\",\"height\":65,\"weight\":120},\"primaryKey\":\"237-23-7739\"}"
cursor.advance(1)
deleteSecond():
PASS expected is "{\"key\":\"237-23-7740\",\"value\":{\"name\":\"Sam\",\"height\":71,\"weight\":110},\"primaryKey\":\"237-23-7740\"}"
cursor.advance(1)
deleteSecond():
PASS expected is "{\"key\":\"237-23-7741\",\"value\":{\"name\":\"Bug\",\"height\":63,\"weight\":100},\"primaryKey\":\"237-23-7741\"}"
cursor.advance(1)
deleteSecond():
PASS expected is "{\"key\":\"237-23-7742\",\"value\":{\"name\":\"Tub\",\"height\":69,\"weight\":180},\"primaryKey\":\"237-23-7742\"}"
cursor.advance(1)
deleteSecond():
PASS expected is "{\"key\":\"237-23-7743\",\"value\":{\"name\":\"Rug\",\"height\":77,\"weight\":120},\"primaryKey\":\"237-23-7743\"}"
cursor.advance(1)
deleteSecond():
PASS expected is "{\"key\":\"237-23-7744\",\"value\":{\"name\":\"Pug\",\"height\":66,\"weight\":110},\"primaryKey\":\"237-23-7744\"}"
cursor.advance(1)
deleteSecond():
PASS successfullyParsed is true
TEST COMPLETE