1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test calling db.open in upgradeneeded.");
12 request = evalAndLog("indexedDB.deleteDatabase(dbname)");
13 request.onsuccess = deleteSuccess;
14 request.onerror = unexpectedErrorCallback;
17 function deleteSuccess(evt) {
18 evalAndLog("request = indexedDB.open(dbname, 1)");
19 evalAndLog("request.onupgradeneeded = upgradeNeeded1");
20 evalAndLog("request.onsuccess = openSuccess1");
21 request.onblocked = unexpectedBlockedCallback;
22 request.onerror = unexpectedErrorCallback;
25 var sawTransactionComplete = false;
26 function upgradeNeeded1(evt)
29 evalAndLog("db = event.target.result");
30 shouldBe("event.newVersion", "1");
32 evalAndLog("transaction = event.target.transaction");
33 evalAndLog("db.createObjectStore('os')");
34 transaction.onabort = unexpectedAbortCallback;
35 transaction.oncomplete = function transactionOnComplete() {
37 evalAndLog("sawTransactionComplete = true");
39 evalAndLog("db.onversionchange = onVersionChange");
40 evalAndLog("request = indexedDB.open(dbname, 3)");
41 evalAndLog("request.onupgradeneeded = upgradeNeeded2");
42 evalAndLog("request.onsuccess = openSuccess2");
43 request.onblocked = unexpectedBlockedCallback;
44 request.onerror = unexpectedErrorCallback;
47 function openSuccess1(evt)
50 shouldBeTrue("sawTransactionComplete");
51 db = evalAndLog("db = event.target.result");
52 shouldBe('db.version', "1");
53 debug("Start a transaction to ensure the connection is still open.");
54 evalAndLog("transaction = db.transaction('os')");
57 function onVersionChange(evt)
60 evalAndLog("db.close()");
63 function upgradeNeeded2(evt)
66 evalAndLog("db = event.target.result");
67 shouldBe("event.newVersion", "3");
70 function openSuccess2(evt)
73 evalAndLog("db = event.target.result");
74 shouldBe("db.version", "3");