blob: 6702d88d47ca049239ed2b10f7421ff109b597f4 [file] [log] [blame]
Test IndexedDB's transaction and objectStore calls
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
dbname = "transaction-and-objectstore-calls.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
db.createObjectStore('a')
db.createObjectStore('b')
db.createObjectStore('store').createIndex('index', 'some_path')
trans = db.transaction(['a'])
trans.objectStore('a')
Expecting exception from trans.objectStore('b')
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
Expecting exception from trans.objectStore('x')
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
trans = db.transaction(['a'])
trans.objectStore('a')
Expecting exception from trans.objectStore('b')
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
Expecting exception from trans.objectStore('x')
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
trans = db.transaction(['b'])
trans.objectStore('b')
Expecting exception from trans.objectStore('a')
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
Expecting exception from trans.objectStore('x')
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
trans = db.transaction(['a', 'b'])
trans.objectStore('a')
trans.objectStore('b')
Expecting exception from trans.objectStore('x')
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
trans = db.transaction(['b', 'a'])
trans.objectStore('a')
trans.objectStore('b')
Expecting exception from trans.objectStore('x')
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
Passing a string as the first argument is a shortcut for just one object store:
trans = db.transaction('a')
trans.objectStore('a')
Expecting exception from trans.objectStore('b')
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
Expecting exception from trans.objectStore('x')
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
PASS trans = db.transaction() threw exception TypeError: Failed to execute 'transaction' on 'IDBDatabase': 1 argument required, but only 0 present..
Expecting exception from db.transaction(['x'])
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Expecting exception from db.transaction(['x'])
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Expecting exception from db.transaction(['a', 'x'])
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Expecting exception from db.transaction(['x', 'x'])
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Expecting exception from db.transaction(['a', 'x', 'b'])
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Exception thrown when no stores specified:
Expecting exception from db.transaction([])
PASS Exception was thrown.
PASS code is DOMException.INVALID_ACCESS_ERR
Exception message: Failed to execute 'transaction' on 'IDBDatabase': The storeNames parameter was empty.
{} coerces to a string - so no match, but not a type error:
Expecting exception from db.transaction({})
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Expecting exception from db.transaction({mode:0})
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Overriding the default string coercion makes these work:
db.transaction({toString:function(){return 'a';}})
db.transaction([{toString:function(){return 'a';}}])
... but you still need to specify a real store:
Expecting exception from db.transaction([{toString:function(){return 'x';}}])
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Expecting exception from db.transaction([{toString:function(){return 'x';}}])
PASS Exception was thrown.
PASS code is DOMException.NOT_FOUND_ERR
PASS ename is 'NotFoundError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
trans = db.transaction(['store'])
PASS trans is non-null.
store = trans.objectStore('store')
PASS store is non-null.
store.get('some_key')
transaction complete, ensuring methods fail
PASS trans is non-null.
PASS store is non-null.
Expecting exception from trans.objectStore('store')
PASS Exception was thrown.
PASS code is DOMException.INVALID_STATE_ERR
PASS ename is 'InvalidStateError'
Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The transaction has finished.
Expecting exception from store.index('index')
PASS Exception was thrown.
PASS code is DOMException.INVALID_STATE_ERR
PASS ename is 'InvalidStateError'
Exception message: Failed to execute 'index' on 'IDBObjectStore': The transaction has finished.
PASS successfullyParsed is true
TEST COMPLETE