IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / test / data / indexeddb / callback_accounting.js
blob8850800840a79dc476e1214c579643de7c9cc9e0
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 function test()
7 var dbbase = "callback_accounting_";
9 var request1 = indexedDB.open(dbbase + 1);
11 request1.onupgradeneeded = function() {
12 debug("request1 open onupgradeneeded");
13 request1.result.createObjectStore('store');
16 request1.onsuccess = function() {
17 debug("request1 open onsuccess");
19 var db1 = request1.result;
20 var transaction = db1.transaction('store');
21 transaction.onabort = unexpectedAbortCallback;
23 debug("transaction created and looping");
24 endTransaction = false;
25 transactionRunning = true;
26 function loop() {
27 if (!endTransaction) {
28 transaction.objectStore('store').get(0).onsuccess = loop;
31 loop();
33 var request2 = indexedDB.open(dbbase + 2);
35 request2.onsuccess = function() {
36 debug("request2 open onsuccess");
38 shouldBeTrue("transactionRunning");
39 var db2 = request2.result;
40 db2.close();
41 debug("db2 close2");
42 endTransaction = true;
43 debug("ending transaction");
46 transaction.oncomplete = function() {
47 debug("transaction oncomplete");
48 shouldBeTrue("endTransaction");
49 done();