65 lines
2.6 KiB
Plaintext
65 lines
2.6 KiB
Plaintext
Test the basics of IndexedDB's IDBDatabase.
|
|
|
|
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)
|
|
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-private.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
|
|
PASS db.objectStoreNames.contains() threw exception TypeError: Not enough arguments.
|
|
db.close()
|
|
request = indexedDB.open(dbname, 2)
|
|
db = event.target.result
|
|
PASS db.version is 2
|
|
PASS db.name is "database-basics-private.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
|
|
PASS db.objectStoreNames.contains() threw exception TypeError: Not enough arguments.
|
|
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
|
|
PASS db.objectStoreNames.contains() threw exception TypeError: Not enough arguments.
|
|
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
|
|
|