1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test that a database is recreated correctly when an open-with-version call is queued behind a deleteDatabase call");
11 request = evalAndLog("indexedDB.deleteDatabase(dbname)");
12 request.onsuccess = deleteSuccess;
13 request.onerror = unexpectedErrorCallback;
16 function deleteSuccess(evt) {
19 evalAndLog("request = indexedDB.open(dbname)");
20 evalAndLog("request.onsuccess = firstSuccessCallback");
21 request.onerror = unexpectedErrorCallback;
24 function firstSuccessCallback(evt)
28 debug("firstSuccessCallback():");
29 evalAndLog("connection1 = event.target.result");
30 evalAndLog("connection1.onversionchange = connection1VersionChangeCallback");
31 evalAndLog("request = indexedDB.open(dbname)");
32 evalAndLog("request.onsuccess = secondSuccessCallback");
33 request.onerror = unexpectedErrorCallback;
35 evalAndLog("request = indexedDB.deleteDatabase(dbname)");
36 evalAndLog("request.onblocked = deleteDatabaseBlockedCallback");
37 evalAndLog("request.onsuccess = deleteDatabaseSuccessCallback");
38 request.onerror = unexpectedErrorCallback;
40 evalAndLog("request = indexedDB.open(dbname, 1)");
41 evalAndLog("request.onupgradeneeded = upgradeNeededCallback");
42 evalAndLog("request.onsuccess = openWithVersionSuccessCallback");
43 request.onblocked = unexpectedBlockedCallback;
44 request.onerror = unexpectedErrorCallback;
47 function secondSuccessCallback(evt)
50 evalAndLog("db = event.target.result");
51 evalAndLog("db.onversionchange = connection2VersionChangeCallback");
54 function connection1VersionChangeCallback(evt)
57 shouldBeEqualToString("event.type", "versionchange");
58 shouldBe("event.oldVersion", "1");
59 shouldBeNull("event.newVersion");
62 function connection2VersionChangeCallback(evt)
65 shouldBeEqualToString("event.type", "versionchange");
66 evalAndLog("event.target.close()");
69 function deleteDatabaseBlockedCallback(evt)
72 evalAndLog("connection1.close()");
75 function deleteDatabaseSuccessCallback(evt)
80 function upgradeNeededCallback(evt)
83 shouldBe("event.newVersion", "1");
84 shouldBe("event.oldVersion", "0");
87 function openWithVersionSuccessCallback(evt)
90 shouldBe("event.target.result.objectStoreNames.length", "0");