1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB opening database connections during transactions");
8 indexedDBTest(prepareDatabase, startTransaction);
9 function prepareDatabase()
11 dbc1 = event.target.result;
12 evalAndLog("dbc1.createObjectStore('storeName')");
13 event.target.transaction.oncomplete = function (e) {
14 debug("database preparation complete");
19 function startTransaction()
21 debug("starting transaction");
22 evalAndLog("state = 'starting'");
23 evalAndLog("trans = dbc1.transaction('storeName', 'readwrite')");
25 debug("the transaction is kept alive with a series of puts until opens are complete");
26 (function keepAlive() {
27 // Don't log, since this may run an arbitrary number of times.
28 if (state !== 'open3complete') {
29 var request = trans.objectStore('storeName').put('value', 'key');
30 request.onerror = unexpectedErrorCallback;
31 request.onsuccess = keepAlive;
35 trans.onabort = unexpectedAbortCallback;
36 trans.onerror = unexpectedErrorCallback;
37 trans.oncomplete = function (e) {
38 debug("transaction complete");
39 shouldBeEqualToString("state", "open3complete");
50 debug("trying to open the same database");
51 evalAndLog("openreq2 = indexedDB.open(dbname)");
52 openreq2.onerror = unexpectedErrorCallback;
53 openreq2.onsuccess = function (e) {
54 debug("openreq2.onsuccess");
55 shouldBeEqualToString("state", "starting");
56 evalAndLog("state = 'open2complete'");
61 debug("trying to open a different database");
62 evalAndLog("openreq3 = indexedDB.open(dbname + '2')");
63 openreq3.onerror = unexpectedErrorCallback;
64 openreq3.onsuccess = function (e) {
65 debug("openreq3.onsuccess");
66 shouldBeEqualToString("state", "open2complete");
67 evalAndLog("state = 'open3complete'");