1 Upgrade a database, open a second connection at the same version, ensure specifying a lower version causes an error
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "intversion-upgrades.html"
7 indexedDB.deleteDatabase(dbname)
8 PASS String(request) is "[object IDBOpenDBRequest]"
10 Call open with no version parameter:
11 indexedDB.open(dbname)
13 initialUpgradeNeeded():
16 connection1 = event.target.result
17 PASS connection1.version is 1
18 connection1.onversionchange = connection1VersionChangeCallback
19 request = indexedDB.open(dbname, 2)
21 connection1VersionChangeCallback():
24 connection2UpgradeNeeded():
25 connection2 = event.target.result
26 PASS String(connection2) is "[object IDBDatabase]"
27 PASS String(request.transaction) is "[object IDBTransaction]"
28 PASS event.oldVersion is 1
29 PASS event.newVersion is 2
30 request.transaction.oncomplete = transactionCompleted
32 transactionCompleted():
33 didTransactionComplete = true
36 PASS didTransactionComplete is true
37 PASS event.target.result is connection2
38 The next connection opens the database at the same version so connection2 shouldn't get a versionchange event.
39 connection2.onversionchange = unexpectedVersionChangeCallback
40 PASS String(connection2) is "[object IDBDatabase]"
41 PASS request.transaction is null
42 PASS connection2.version is 2
43 request = indexedDB.open(dbname, 2)
44 request.onsuccess = connection3Success
45 request.onblocked = unexpectedBlockedCallback
48 event.target.result.close()
50 connection3 = event.target.result
51 PASS connection3.version is 2
52 request = indexedDB.open(dbname, 1)
53 request.onerror = errorWhenTryingLowVersion
55 errorWhenTryingLowVersion():
56 request.error.message = The requested version (1) is less than the existing version (2).
57 request = indexedDB.open(dbname, 4)
58 request.onupgradeneeded = connection4UpgradeNeeded
59 request.onsuccess = connection4Success
61 connection4UpgradeNeeded():
62 gotConnection4UpgradeNeeded = true
63 PASS event.oldVersion is 2
64 PASS event.newVersion is 4
67 PASS gotConnection4UpgradeNeeded is true
68 connection4 = event.target.result
69 PASS connection4.version is 4
71 request = indexedDB.open(dbname)
72 request.onsuccess = connection5Success
75 db = event.target.result
77 PASS successfullyParsed is true