Test IndexedDB transaction basics.

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.open('transaction-basics')
openSuccess():
db = event.target.result
request = db.setVersion('version 1')
Deleted all object stores.
PASS self.db.objectStoreNames is []
PASS self.db.objectStoreNames.length is 0
PASS self.db.objectStoreNames.contains('storeFail') is false
request = startSetVersion('version fail')
addRemoveIDBObjects():
trans = event.target.result
PASS trans is non-null.
store = db.createObjectStore('storeFail', null)
index = store.createIndex('indexFail', 'x')
db.deleteObjectStore('storeFail')
Expecting exception from store.deleteIndex('indexFail')
PASS Exception was thrown.
PASS code is DOMException.INVALID_STATE_ERR
PASS ename is 'InvalidStateError'

testSetVersionAbort2():
PASS self.db.objectStoreNames is []
PASS self.db.objectStoreNames.length is 0
PASS self.db.objectStoreNames.contains('storeFail') is false
request = startSetVersion('version fail')
addRemoveAddIDBObjects():
trans = event.target.result
PASS trans is non-null.
store = db.createObjectStore('storeFail', null)
index = store.createIndex('indexFail', 'x')
db.deleteObjectStore('storeFail')
Expecting exception from store.deleteIndex('indexFail')
PASS Exception was thrown.
PASS code is DOMException.INVALID_STATE_ERR
PASS ename is 'InvalidStateError'
store = db.createObjectStore('storeFail', null)
index = store.createIndex('indexFail', 'x')

testSetVersionAbort3():
PASS event.cancelable is false
PASS self.db.objectStoreNames is []
PASS self.db.objectStoreNames.length is 0
PASS self.db.objectStoreNames.contains('storeFail') is false
request = startSetVersion('version fail')
addIDBObjects():
PASS event.cancelable is false
trans = event.target.result
PASS trans is non-null.
store = db.createObjectStore('storeFail', null)
index = store.createIndex('indexFail', 'x')

testInactiveAbortedTransaction():
Expecting exception from index.openCursor()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from index.openKeyCursor()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from index.get(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from index.getKey(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from index.count()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.put(0, 0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.add(0, 0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.delete(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.clear()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.get(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.openCursor()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'

testSetVersionAbort4():
PASS self.db.objectStoreNames is []
PASS self.db.objectStoreNames.length is 0
PASS self.db.objectStoreNames.contains('storeFail') is false
request = startSetVersion('version fail')
addIDBObjectsAndCommit():
trans = event.target.result
PASS trans is non-null.
store = db.createObjectStore('storeFail', null)
index = store.createIndex('indexFail', 'x')

testInactiveCompletedTransaction():
Expecting exception from index.openCursor()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from index.openKeyCursor()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from index.get(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from index.getKey(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from index.count()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.put(0, 0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.add(0, 0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.delete(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.clear()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.get(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'
Expecting exception from store.openCursor()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
PASS ename is 'TransactionInactiveError'

testSetVersionAbort5():
PASS db.objectStoreNames is ['storeFail']
PASS db.objectStoreNames.length is 1
PASS db.objectStoreNames.contains('storeFail') is true
request = startSetVersion('version fail')
removeIDBObjects():
trans = event.target.result
PASS trans is non-null.
store = trans.objectStore('storeFail')
store.deleteIndex('indexFail')
db.deleteObjectStore('storeFail')

testSetVersionAbort6():
PASS db.objectStoreNames is ['storeFail']
PASS db.objectStoreNames.length is 1
PASS db.objectStoreNames.contains('storeFail') is true
db.setVersion('new version')

setVersionSuccess():
trans = event.target.result
PASS trans is non-null.
Deleted all object stores.
db.createObjectStore('storeName', null)
PASS event.cancelable is false
PASS complete event fired
db.transaction(['storeName'])
store = transaction.objectStore('storeName')
PASS store.name is "storeName"
PASS abort event fired

Verifying DOMStringList works as argument for IDBDatabase.transaction()
db.objectStoreNames is [object DOMStringList]
... which contains: ["storeName"]
transaction = db.transaction(db.objectStoreNames)
PASS no exception thrown
PASS transaction.objectStore("storeName") is non-null.
PASS all stores present in transaction

Verify that specifying an invalid mode raises an exception
Expecting exception from db.transaction(['storeName'], 'lsakjdf')
PASS Exception was thrown.
PASS code is IDBDatabaseException.TYPE_ERR
PASS ename is 'TypeError'
PASS successfullyParsed is true

TEST COMPLETE

