Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: chrome/test/data/indexeddb/transaction_test.js

Issue 6209005: Fix IndexedDB race condition during shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First stab at new approach Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 emplyeeNotFound()
17 { 17 {
18 debug('Employee not found.'); 18 debug('Employee not found.');
19 } 19 }
20 20
21 function newTransactionAborted() 21 function newTransactionAborted()
22 { 22 {
23 debug('The transaction was aborted.'); 23 debug('The transaction was aborted.');
24 24
25 var finalTransaction = db.transaction([], IDBTransaction.READ_ONLY, 0); 25 var finalTransaction = db.transaction({objectStoreNames: [], mode: IDBTransact ion.READ_ONLY});
26 finalTransaction.oncomplete = finalTransactionCompleted; 26 finalTransaction.oncomplete = finalTransactionCompleted;
27 finalTransaction.onabort = finalTransactionAborted; 27 finalTransaction.onabort = finalTransactionAborted;
28 28
29 var request = finalTransaction.objectStore('employees').get(0); 29 var request = finalTransaction.objectStore('employees').get(0);
30 request.onsuccess = unexpectedSuccessCallback; 30 request.onsuccess = unexpectedSuccessCallback;
31 request.onerror = emplyeeNotFound; 31 request.onerror = emplyeeNotFound;
32 } 32 }
33 33
34 function newTransactionCompleted() 34 function newTransactionCompleted()
35 { 35 {
36 fail('The new transaction should not complete.'); 36 fail('The new transaction should not complete.');
37 } 37 }
38 38
39 function employeeAdded() 39 function employeeAdded()
40 { 40 {
41 debug('Added an employee inside the transaction.'); 41 debug('Added an employee inside the transaction.');
42 } 42 }
43 43
44 function onSetVersionComplete() 44 function onSetVersionComplete()
45 { 45 {
46 debug('Creating new transaction.'); 46 debug('Creating new transaction.');
47 var newTransaction = db.transaction([], IDBTransaction.READ_WRITE, 0); 47 var newTransaction = db.transaction({objectStoreNames: [], mode: IDBTransactio n.READ_WRITE});
48 newTransaction.oncomplete = newTransactionCompleted; 48 newTransaction.oncomplete = newTransactionCompleted;
49 newTransaction.onabort = newTransactionAborted; 49 newTransaction.onabort = newTransactionAborted;
50 50
51 var request = newTransaction.objectStore('employees').put( 51 var request = newTransaction.objectStore('employees').put(
52 {id: 0, name: 'John Doe', desk: 'LON-BEL-123'}); 52 {id: 0, name: 'John Doe', desk: 'LON-BEL-123'});
53 request.onsuccess = employeeAdded; 53 request.onsuccess = employeeAdded;
54 request.onerror = unexpectedErrorCallback; 54 request.onerror = unexpectedErrorCallback;
55 55
56 newTransaction.abort(); 56 newTransaction.abort();
57 } 57 }
(...skipping 25 matching lines...) Expand all
83 IDBCursor = webkitIDBCursor; 83 IDBCursor = webkitIDBCursor;
84 IDBKeyRange = webkitIDBKeyRange; 84 IDBKeyRange = webkitIDBKeyRange;
85 IDBTransaction = webkitIDBTransaction; 85 IDBTransaction = webkitIDBTransaction;
86 } 86 }
87 87
88 debug('Connecting to indexedDB.'); 88 debug('Connecting to indexedDB.');
89 var result = indexedDB.open('name'); 89 var result = indexedDB.open('name');
90 result.onsuccess = setVersion; 90 result.onsuccess = setVersion;
91 result.onerror = unexpectedErrorCallback; 91 result.onerror = unexpectedErrorCallback;
92 } 92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698