1 Test the basics of IndexedDB's IDBDatabase.
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "database-basics.html"
7 indexedDB.deleteDatabase(dbname)
9 Test that you can't open a transaction while in a versionchange transaction
10 Expecting exception from db.transaction("doesntExist")
11 PASS Exception was thrown.
12 PASS code is DOMException.INVALID_STATE_ERR
13 PASS ename is 'InvalidStateError'
14 Exception message: Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running.
16 PASS db.name is "database-basics.html"
17 PASS db.objectStoreNames is []
18 PASS db.objectStoreNames.length is 0
19 PASS db.objectStoreNames.contains('') is false
20 PASS db.objectStoreNames[0] is undefined.
21 PASS db.objectStoreNames.item(0) is null
22 db.createObjectStore("test123")
23 PASS db.objectStoreNames is ['test123']
24 PASS db.objectStoreNames.length is 1
25 PASS db.objectStoreNames.contains('') is false
26 PASS db.objectStoreNames.contains('test456') is false
27 PASS db.objectStoreNames.contains('test123') is true
29 request = indexedDB.open(dbname, 2)
30 db = event.target.result
32 PASS db.name is "database-basics.html"
33 PASS db.objectStoreNames is ['test123']
34 PASS db.objectStoreNames.length is 1
35 PASS db.objectStoreNames.contains('') is false
36 PASS db.objectStoreNames.contains('test456') is false
37 PASS db.objectStoreNames.contains('test123') is true
38 db.createObjectStore("test456")
39 setVersionTrans = event.target.transaction
40 PASS setVersionTrans is non-null.
41 setVersionTrans.abort()
43 PASS db.objectStoreNames is ['test123']
44 PASS db.objectStoreNames.length is 1
45 PASS db.objectStoreNames.contains('') is false
46 PASS db.objectStoreNames.contains('test456') is false
47 PASS db.objectStoreNames.contains('test123') is true
49 Now that the connection is closed, transaction creation should fail
50 Expecting exception from db.transaction('test123')
51 PASS Exception was thrown.
52 PASS code is DOMException.INVALID_STATE_ERR
53 PASS ename is 'InvalidStateError'
54 Exception message: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.
55 Call twice, make sure it's harmless
57 PASS successfullyParsed is true