OLD | NEW |
| (Empty) |
1 CONSOLE MESSAGE: line 73: Error: This should *NOT* be caught! | |
2 Test IDBTransaction.error cases. | |
3 | |
4 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". | |
5 | |
6 | |
7 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; | |
8 | |
9 dbname = "transaction-error.html" | |
10 indexedDB.deleteDatabase(dbname) | |
11 indexedDB.open(dbname) | |
12 store = db.createObjectStore('storeName') | |
13 store.add('value', 'key') | |
14 | |
15 trans = db.transaction('storeName') | |
16 | |
17 IDBTransaction.error should be null if transaction is not finished: | |
18 PASS trans.error is null | |
19 | |
20 If IDBTransaction.abort() is explicitly called, IDBTransaction.error should be n
ull: | |
21 trans.abort() | |
22 PASS trans.error is null | |
23 | |
24 If the transaction is aborted due to a request error that is not prevented, IDBT
ransaction.error should match: | |
25 trans = db.transaction('storeName', 'readwrite') | |
26 request = trans.objectStore('storeName').add('value2', 'key') | |
27 PASS request.error.name is 'ConstraintError' | |
28 request_error = request.error | |
29 Transaction received abort event. | |
30 PASS trans.error is non-null. | |
31 trans.webkitErrorMessage = Key already exists in the object store. | |
32 PASS trans.webkitErrorMessage is non-null. | |
33 PASS trans.error is request_error | |
34 | |
35 If the transaction is aborted due to an exception thrown from event callback, ID
BTransaction.error should be AbortError: | |
36 trans = db.transaction('storeName', 'readwrite') | |
37 request = trans.objectStore('storeName').add('value2', 'key') | |
38 PASS request.error.name is 'ConstraintError' | |
39 Throwing exception... | |
40 Transaction received abort event. | |
41 PASS trans.error is non-null. | |
42 trans.webkitErrorMessage = Uncaught exception in event handler. | |
43 PASS trans.webkitErrorMessage is non-null. | |
44 PASS trans.error.name is 'AbortError' | |
45 | |
46 If the transaction is aborted due to an error during commit, IDBTransaction.erro
r should reflect that error: | |
47 trans = db.transaction('storeName', 'readwrite') | |
48 request = trans.objectStore('storeName').add({id: 1}, 'record1') | |
49 request = trans.objectStore('storeName').add({id: 1}, 'record2') | |
50 request = indexedDB.open(dbname, 2) | |
51 trans = request.transaction | |
52 This should fail due to the unique constraint: | |
53 indexName = 'Also test utf8: 漢' | |
54 trans.objectStore('storeName').createIndex(indexName, 'id', {unique: true}) | |
55 Transaction received abort event. | |
56 PASS trans.error is non-null. | |
57 PASS trans.error.name is 'ConstraintError' | |
58 trans.webkitErrorMessage = Unable to add key to index 'Also test utf8: æ¼¢': at
least one key does not satisfy the uniqueness requirements. | |
59 PASS trans.webkitErrorMessage is non-null. | |
60 Note: This fails because of http://wkb.ug/37327 | |
61 FAIL trans.webkitErrorMessage.indexOf(indexName) should not be -1. | |
62 | |
63 PASS successfullyParsed is true | |
64 | |
65 TEST COMPLETE | |
66 | |
OLD | NEW |