1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test that only the first open call gets an upgradeneeded");
12 request = evalAndLog("indexedDB.deleteDatabase(dbname)");
13 request.onsuccess = deleteSuccess;
14 request.onerror = unexpectedErrorCallback;
17 var gotFirstUpgradeNeededEvent = false;
18 var gotSecondUpgradeNeededEvent = false;
19 function deleteSuccess(evt) {
20 request = evalAndLog("indexedDB.open(dbname)");
21 evalAndLog("request.onsuccess = connection1OpenSuccess");
22 evalAndLog("request.onupgradeneeded = connection1UpgradeNeeded");
23 request.onerror = unexpectedErrorCallback;
24 request.onblocked = unexpectedBlockedCallback;
26 request = evalAndLog("indexedDB.open(dbname)");
27 evalAndLog("request.onsuccess = connection2OpenSuccess");
28 evalAndLog("request.onupgradeneeded = connection2UpgradeNeeded");
29 request.onerror = unexpectedErrorCallback;
30 request.onblocked = unexpectedBlockedCallback;
33 function connection1UpgradeNeeded(evt)
36 evalAndLog("gotFirstUpgradeNeededEvent = true");
37 shouldBe("event.oldVersion", "0");
38 shouldBe("event.newVersion", "1");
41 function connection1OpenSuccess(evt)
44 db = evalAndLog("db = event.target.result");
45 shouldBeTrue("gotFirstUpgradeNeededEvent");
46 shouldBe("db.version", "1");
49 function connection2UpgradeNeeded(evt)
52 evalAndLog("gotSecondUpgradeNeededEvent = true");
55 function connection2OpenSuccess(evt)
58 db = evalAndLog("db = event.target.result");
59 shouldBeFalse("gotSecondUpgradeNeededEvent");
60 shouldBe("db.version", "1");