| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 function finalTransactionCompleted() | 5 function finalTransactionCompleted() |
| 6 { | 6 { |
| 7 debug('The final transaction completed.'); | 7 debug('The final transaction completed.'); |
| 8 done(); | 8 done(); |
| 9 } | 9 } |
| 10 | 10 |
| 11 function finalTransactionAborted() | 11 function finalTransactionAborted() |
| 12 { | 12 { |
| 13 fail('The final transaction should not abort.'); | 13 fail('The final transaction should not abort.'); |
| 14 } | 14 } |
| 15 | 15 |
| 16 function emplyeeNotFound() | 16 function employeeNotFound() |
| 17 { | 17 { |
| 18 debug('Employee not found.'); | 18 debug('Employee not found.'); |
| 19 shouldBe("event.result", "undefined"); |
| 19 } | 20 } |
| 20 | 21 |
| 21 function newTransactionAborted() | 22 function newTransactionAborted() |
| 22 { | 23 { |
| 23 debug('The transaction was aborted.'); | 24 debug('The transaction was aborted.'); |
| 24 | 25 |
| 25 var finalTransaction = db.transaction([], IDBTransaction.READ_ONLY, 0); | 26 var finalTransaction = db.transaction({objectStoreNames: [], mode: IDBTransact
ion.READ_ONLY}); |
| 26 finalTransaction.oncomplete = finalTransactionCompleted; | 27 finalTransaction.oncomplete = finalTransactionCompleted; |
| 27 finalTransaction.onabort = finalTransactionAborted; | 28 finalTransaction.onabort = finalTransactionAborted; |
| 28 | 29 |
| 29 var request = finalTransaction.objectStore('employees').get(0); | 30 var request = finalTransaction.objectStore('employees').get(0); |
| 30 request.onsuccess = unexpectedSuccessCallback; | 31 request.onsuccess = employeeNotFound; |
| 31 request.onerror = emplyeeNotFound; | 32 request.onerror = unexpectedErrorCallback; |
| 32 } | 33 } |
| 33 | 34 |
| 34 function newTransactionCompleted() | 35 function newTransactionCompleted() |
| 35 { | 36 { |
| 36 fail('The new transaction should not complete.'); | 37 fail('The new transaction should not complete.'); |
| 37 } | 38 } |
| 38 | 39 |
| 39 function employeeAdded() | 40 function employeeAdded() |
| 40 { | 41 { |
| 41 debug('Added an employee inside the transaction.'); | 42 debug('Added an employee inside the transaction.'); |
| 42 } | 43 } |
| 43 | 44 |
| 44 function onSetVersionComplete() | 45 function onSetVersionComplete() |
| 45 { | 46 { |
| 46 debug('Creating new transaction.'); | 47 debug('Creating new transaction.'); |
| 47 var newTransaction = db.transaction([], IDBTransaction.READ_WRITE, 0); | 48 var newTransaction = db.transaction({objectStoreNames: [], mode: IDBTransactio
n.READ_WRITE}); |
| 48 newTransaction.oncomplete = newTransactionCompleted; | 49 newTransaction.oncomplete = newTransactionCompleted; |
| 49 newTransaction.onabort = newTransactionAborted; | 50 newTransaction.onabort = newTransactionAborted; |
| 50 | 51 |
| 51 var request = newTransaction.objectStore('employees').put( | 52 var request = newTransaction.objectStore('employees').put( |
| 52 {id: 0, name: 'John Doe', desk: 'LON-BEL-123'}); | 53 {id: 0, name: 'John Doe', desk: 'LON-BEL-123'}); |
| 53 request.onsuccess = employeeAdded; | 54 request.onsuccess = employeeAdded; |
| 54 request.onerror = unexpectedErrorCallback; | 55 request.onerror = unexpectedErrorCallback; |
| 55 | 56 |
| 56 newTransaction.abort(); | 57 newTransaction.abort(); |
| 57 } | 58 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 83 IDBCursor = webkitIDBCursor; | 84 IDBCursor = webkitIDBCursor; |
| 84 IDBKeyRange = webkitIDBKeyRange; | 85 IDBKeyRange = webkitIDBKeyRange; |
| 85 IDBTransaction = webkitIDBTransaction; | 86 IDBTransaction = webkitIDBTransaction; |
| 86 } | 87 } |
| 87 | 88 |
| 88 debug('Connecting to indexedDB.'); | 89 debug('Connecting to indexedDB.'); |
| 89 var result = indexedDB.open('name'); | 90 var result = indexedDB.open('name'); |
| 90 result.onsuccess = setVersion; | 91 result.onsuccess = setVersion; |
| 91 result.onerror = unexpectedErrorCallback; | 92 result.onerror = unexpectedErrorCallback; |
| 92 } | 93 } |
| OLD | NEW |