1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test the order when there are pending setVersion, delete and open calls.");
8 indexedDBTest(null, h1OpenSuccess);
9 function h1OpenSuccess(evt)
12 evalAndLog("setVersionBlockedEventFired = false");
13 evalAndLog("versionChangeComplete = false");
14 evalAndLog("deleteDatabaseBlockedEventFired = false");
15 evalAndLog("deleteDatabaseComplete = false");
17 evalAndLog("h1 = event.target.result");
19 h1.onversionchange = function h1OnVersionChange(evt) {
21 shouldBe("event.target.version", "1");
22 shouldBe("event.oldVersion", "1");
23 shouldBe("event.newVersion", "2");
25 h1.onversionchange = function h1SecondOnVersionChange(evt) {
27 shouldBe("event.target.version", "1");
28 shouldBe("event.oldVersion", "1");
29 shouldBeNull("event.newVersion");
34 request = evalAndLog("indexedDB.open(dbname)");
35 request.onblocked = unexpectedBlockedCallback;
36 request.onerror = unexpectedErrorCallback;
37 request.onsuccess = function h2OpenSuccess(evt) {
39 h2 = event.target.result;
41 h2.onversionchange = function h2OnVersionChange(evt) {
43 shouldBe("event.target.version", "1");
44 shouldBe("event.oldVersion", "1");
45 shouldBe("event.newVersion", "2");
47 h2.onversionchange = function h2OnSecondVersionChange(evt) {
49 shouldBe("event.target.version", "1");
50 shouldBe("event.oldVersion", "1");
51 shouldBe("event.newVersion", "null");
55 debug("Try to open h3:");
56 request = evalAndLog("indexedDB.open(dbname, 2)");
57 request.onerror = unexpectedErrorCallback;
58 request.onsuccess = function h3OpenSuccess(evt) {
60 h3 = event.target.result;
61 evalAndLog("h3.close()");
63 request.onblocked = function h3Blocked(evt) {
65 evalAndLog("setVersionBlockedEventFired = true");
67 debug("Try to open h4:");
68 request = evalAndLog("indexedDB.open(dbname)");
69 request.onblocked = unexpectedBlockedCallback;
70 request.onerror = unexpectedErrorCallback;
71 request.onsuccess = function h4OpenSuccess(evt) {
73 h4 = event.target.result;
74 h4.onversionchange = unexpectedVersionChangeCallback;
76 shouldBeTrue("setVersionBlockedEventFired");
77 shouldBeTrue("versionChangeComplete");
78 shouldBeTrue("deleteDatabaseBlockedEventFired");
79 shouldBeTrue("deleteDatabaseComplete");
84 evalAndLog("h2.close()");
86 request.onupgradeneeded = function h3OnUpgradeneeded(evt) {
89 transaction = event.target.transaction;
90 transaction.onabort = unexpectedAbortCallback;
91 transaction.oncomplete = function transactionOnComplete(evt) {
93 evalAndLog("versionChangeComplete = true");
97 request = evalAndLog("indexedDB.deleteDatabase(dbname)");
98 request.onerror = unexpectedErrorCallback;
99 request.onblocked = function deleteDatabaseOnBlocked(evt) {
101 evalAndLog("deleteDatabaseBlockedEventFired = true");
103 evalAndLog("h1.close()");
105 request.onsuccess = function deleteDatabaseOnSuccess(evt) {
107 evalAndLog("deleteDatabaseComplete = true");