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;
PASS Boolean(indexedDB && IDBCursor && IDBDatabase && IDBDatabaseError && IDBDatabaseException && IDBFactory && IDBIndex && IDBKeyRange && IDBObjectStore && IDBRequest && IDBTransaction) is true

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 !== null is true
store = db.createObjectStore('storeFail', null)
index = store.createIndex('indexFail', 'x')
db.deleteObjectStore('storeFail')
store.deleteIndex('indexFail')

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 !== null is true
store = db.createObjectStore('storeFail', null)
index = store.createIndex('indexFail', 'x')
db.deleteObjectStore('storeFail')
store.deleteIndex('indexFail')
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 !== null is true
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
Expecting exception from index.openKeyCursor()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from index.get(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from index.getKey(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from index.count()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.put(0, 0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.add(0, 0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.delete(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.clear()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.get(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.openCursor()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR

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 !== null is true
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
Expecting exception from index.openKeyCursor()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from index.get(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from index.getKey(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from index.count()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.put(0, 0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.add(0, 0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.delete(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.clear()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.get(0)
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR
Expecting exception from store.openCursor()
PASS Exception was thrown.
PASS code is IDBDatabaseException.TRANSACTION_INACTIVE_ERR

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 !== null is true
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 !== null is true
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") != null is true
PASS all stores present in transaction

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

TEST COMPLETE

