1 CONSOLE ERROR: line 82: Uncaught Error: This should *NOT* be caught!
2 Test IDBTransaction.error cases.
4 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
7 dbname = "transaction-error.html"
8 indexedDB.deleteDatabase(dbname)
10 store = db.createObjectStore('storeName')
11 store.add('value', 'key')
13 trans = db.transaction('storeName')
15 IDBTransaction.error should be null if transaction is not finished:
16 PASS trans.error is null
18 transaction() should throw if one of the DOMStringList items cannot be converted to a String:
19 PASS db.transaction(['storeName', nonConvertibleToString]) threw exception Exception in toString().
21 If IDBTransaction.abort() is explicitly called, IDBTransaction.error should be null:
23 PASS trans.error is null
25 If the transaction is aborted due to a request error that is not prevented, IDBTransaction.error should match:
26 trans = db.transaction('storeName', 'readwrite')
27 request = trans.objectStore('storeName').add('value2', 'key')
28 PASS request.result is undefined.
29 PASS request.error is non-null.
30 PASS request.error.name is 'ConstraintError'
31 request_error = request.error
32 Transaction received abort event.
33 PASS trans.error is non-null.
34 trans.error.message = Key already exists in the object store.
35 PASS trans.error.message is non-null.
36 PASS trans.error is request_error
38 If the transaction is aborted due to an exception thrown from event callback, IDBTransaction.error should be AbortError:
39 trans = db.transaction('storeName', 'readwrite')
40 request = trans.objectStore('storeName').add('value2', 'key')
41 PASS request.result is undefined.
42 PASS request.error is non-null.
43 PASS request.error.name is 'ConstraintError'
45 Transaction received abort event.
46 PASS trans.error is non-null.
47 trans.error.message = Uncaught exception in event handler.
48 PASS trans.error.message is non-null.
49 PASS trans.error.name is 'AbortError'
51 If the transaction is aborted due to an error during commit, IDBTransaction.error should reflect that error:
52 trans = db.transaction('storeName', 'readwrite')
53 request = trans.objectStore('storeName').add({id: 1}, 'record1')
54 request = trans.objectStore('storeName').add({id: 1}, 'record2')
55 request = indexedDB.open(dbname, 2)
56 trans = request.transaction
57 This should fail due to the unique constraint:
58 indexName = 'Also test utf8: 漢'
59 trans.objectStore('storeName').createIndex(indexName, 'id', {unique: true})
60 Transaction received abort event.
61 PASS trans.error is non-null.
62 PASS trans.error.name is 'ConstraintError'
63 trans.error.message = Unable to add key to index 'Also test utf8: 漢': at least one key does not satisfy the uniqueness requirements.
64 PASS trans.error.message is non-null.
65 Note: This fails because of http://wkb.ug/37327
66 PASS trans.error.message.indexOf(indexName) is not -1
68 PASS successfullyParsed is true