1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Ensure pending open waits for version change transaction to complete.");
8 indexedDBTest(prepareDatabase, null, {"runAfterOpen": concurrentOpen});
10 function concurrentOpen()
12 debug("calling open() - callback should wait until VERSION_CHANGE transaction is complete");
13 var openRequest = evalAndLog("indexedDB.open(dbname)");
14 openRequest.onsuccess = openAgainSuccess;
15 openRequest.onerror = unexpectedErrorCallback;
18 function prepareDatabase()
20 db = event.target.result;
21 debug("setVersion() callback");
22 debug("starting work in VERSION_CHANGE transaction");
23 evalAndLog("self.state = 'VERSION_CHANGE started'");
25 self.store = evalAndLog("store = db.createObjectStore('test-store')");
26 evalAndExpectException("db.transaction('test-store')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
30 function do_async_puts()
32 var req = evalAndLog("store.put(" + count + ", " + count + ")");
33 req.onerror = unexpectedErrorCallback;
34 req.onsuccess = function (e) {
35 debug("in put's onsuccess");
36 if (++self.count < 10) {
39 debug("ending work in VERSION_CHANGE transaction");
40 evalAndLog("self.state = 'VERSION_CHANGE finished'");
46 function openAgainSuccess()
48 debug("open() callback - this should appear after VERSION_CHANGE transaction ends");
49 shouldBeEqualToString("self.state", "VERSION_CHANGE finished");