52 lines
1.5 KiB
Plaintext
52 lines
1.5 KiB
Plaintext
Test IndexedDB's openCursor.
|
|
|
|
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('test')
|
|
objectStore.add('myValue', 'myKey')
|
|
Opening cursor
|
|
event.target.source.openCursor(keyRange)
|
|
Cursor opened successfully.
|
|
PASS cursor.direction is "next"
|
|
PASS cursor.key is "myKey"
|
|
PASS cursor.value is "myValue"
|
|
|
|
Passing an invalid key into .continue({}).
|
|
Expecting exception from event.target.result.continue({})
|
|
PASS Exception was thrown.
|
|
PASS code is 0
|
|
PASS ename is 'DataError'
|
|
Exception message: Failed to execute 'continue' on 'IDBCursor': The parameter is not a valid key.
|
|
|
|
Opening an empty cursor.
|
|
objectStore.openCursor(keyRange)
|
|
Empty cursor opened successfully.
|
|
PASS cursor is null
|
|
Opening cursor
|
|
event.target.source.openCursor("myKey")
|
|
Cursor opened successfully.
|
|
PASS cursor.direction is "next"
|
|
PASS cursor.key is "myKey"
|
|
PASS cursor.value is "myValue"
|
|
|
|
Passing an invalid key into .continue({}).
|
|
Expecting exception from cursor.continue({})
|
|
PASS Exception was thrown.
|
|
PASS code is 0
|
|
PASS ename is 'DataError'
|
|
Exception message: Failed to execute 'continue' on 'IDBCursor': The parameter is not a valid key.
|
|
|
|
Opening an empty cursor.
|
|
objectStore.openCursor("InexistentKey")
|
|
Empty cursor opened successfully.
|
|
PASS cursor is null
|
|
PASS successfullyParsed is true
|
|
|
|
TEST COMPLETE
|
|
|