blob: 6f998eeac28c7bbd7e190ea25d9fc969eeedaf76 [file] [log] [blame]
Test the basics of IndexedDB's IDBDatabase.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
dbname = "database-basics.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
Test that you can't open a transaction while in a versionchange transaction
Expecting exception from db.transaction("doesntExist")
PASS Exception was thrown.
PASS code is DOMException.INVALID_STATE_ERR
PASS ename is 'InvalidStateError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running.
PASS db.version is 1
PASS db.name is "database-basics.html"
PASS db.objectStoreNames is []
PASS db.objectStoreNames.length is 0
PASS db.objectStoreNames.contains('') is false
PASS db.objectStoreNames[0] is undefined.
PASS db.objectStoreNames.item(0) is null
db.createObjectStore("test123")
PASS db.objectStoreNames is ['test123']
PASS db.objectStoreNames.length is 1
PASS db.objectStoreNames.contains('') is false
PASS db.objectStoreNames.contains('test456') is false
PASS db.objectStoreNames.contains('test123') is true
db.close()
request = indexedDB.open(dbname, 2)
db = event.target.result
PASS db.version is 2
PASS db.name is "database-basics.html"
PASS db.objectStoreNames is ['test123']
PASS db.objectStoreNames.length is 1
PASS db.objectStoreNames.contains('') is false
PASS db.objectStoreNames.contains('test456') is false
PASS db.objectStoreNames.contains('test123') is true
db.createObjectStore("test456")
setVersionTrans = event.target.transaction
PASS setVersionTrans is non-null.
setVersionTrans.abort()
PASS db.version is 1
PASS db.objectStoreNames is ['test123']
PASS db.objectStoreNames.length is 1
PASS db.objectStoreNames.contains('') is false
PASS db.objectStoreNames.contains('test456') is false
PASS db.objectStoreNames.contains('test123') is true
db.close()
Now that the connection is closed, transaction creation should fail
Expecting exception from db.transaction('test123')
PASS Exception was thrown.
PASS code is DOMException.INVALID_STATE_ERR
PASS ename is 'InvalidStateError'
Exception message: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
Call twice, make sure it's harmless
db.close()
PASS successfullyParsed is true
TEST COMPLETE