33 lines
988 B
Plaintext
33 lines
988 B
Plaintext
Test IndexedDB transaction rollback.
|
|
|
|
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)
|
|
db.createObjectStore('myObjectStore')
|
|
PASS db.objectStoreNames.length is 1
|
|
setVersionComplete():
|
|
transaction = db.transaction(['myObjectStore'], 'readwrite')
|
|
store = transaction.objectStore('myObjectStore')
|
|
store.add('rollbackValue', 'rollbackKey123')
|
|
addSuccess():
|
|
PASS event.target.result is "rollbackKey123"
|
|
store.openCursor()
|
|
openCursorSuccess():
|
|
cursor = event.target.result
|
|
abortCallback():
|
|
Transaction was aborted.
|
|
transaction = db.transaction(['myObjectStore'], 'readonly')
|
|
store = transaction.objectStore('myObjectStore')
|
|
store.get('rollbackKey123')
|
|
getSuccess():
|
|
PASS event.target.result is undefined
|
|
PASS cursor.value is "rollbackValue"
|
|
PASS successfullyParsed is true
|
|
|
|
TEST COMPLETE
|
|
|