80 lines
2.5 KiB
Plaintext
80 lines
2.5 KiB
Plaintext
Test IndexedDB database metadata mutation/snapshotting
|
|
|
|
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
|
|
|
|
|
|
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
|
|
|
|
indexedDB.deleteDatabase(dbname)
|
|
indexedDB.open(dbname)
|
|
connection1store1 = connection1.createObjectStore('store1')
|
|
connection1store1.createIndex('index1', 'path')
|
|
PASS connection1.version is 1
|
|
PASS connection1.objectStoreNames.length is 1
|
|
PASS connection1store1.indexNames.length is 1
|
|
Connection's properties should be snapshotted on close
|
|
connection1.close()
|
|
|
|
secondOpen():
|
|
request = indexedDB.open(dbname, 2)
|
|
connection2 = request.result
|
|
trans = request.transaction
|
|
connection2.createObjectStore('store2')
|
|
connection2store1 = trans.objectStore('store1')
|
|
connection2store1.createIndex('index2', 'path')
|
|
PASS connection2.version is 2
|
|
PASS connection2.objectStoreNames.length is 2
|
|
PASS connection2store1.indexNames.length is 2
|
|
Connection's properties should be snapshotted on close
|
|
connection2.close()
|
|
|
|
thirdOpen():
|
|
request = indexedDB.open(dbname, 3)
|
|
connection3 = request.result
|
|
trans = request.transaction
|
|
connection3.createObjectStore('store3')
|
|
connection3store1 = trans.objectStore('store1')
|
|
connection3store1.createIndex('index3', 'path')
|
|
PASS connection3.version is 3
|
|
PASS connection3.objectStoreNames.length is 3
|
|
PASS connection3store1.indexNames.length is 3
|
|
Connection's properties should be reverted on abort
|
|
trans.abort()
|
|
Connection's properties should be snapshotted on close
|
|
connection3.close()
|
|
|
|
fourthOpen():
|
|
request = indexedDB.open(dbname, 4)
|
|
connection4 = request.result
|
|
trans = request.transaction
|
|
connection4.createObjectStore('store4')
|
|
connection4store1 = trans.objectStore('store1')
|
|
connection4store1.createIndex('index4', 'path')
|
|
PASS connection4.version is 4
|
|
PASS connection4.objectStoreNames.length is 3
|
|
PASS connection4store1.indexNames.length is 3
|
|
Connection's properties should be snapshotted on close
|
|
connection4.close()
|
|
|
|
checkState():
|
|
PASS connection1.version is 1
|
|
PASS connection1.objectStoreNames.length is 1
|
|
PASS connection1store1.indexNames.length is 1
|
|
|
|
PASS connection2.version is 2
|
|
PASS connection2.objectStoreNames.length is 2
|
|
PASS connection2store1.indexNames.length is 2
|
|
|
|
PASS connection3.version is 2
|
|
PASS connection3.objectStoreNames.length is 2
|
|
PASS connection3store1.indexNames.length is 2
|
|
|
|
PASS connection4.version is 4
|
|
PASS connection4.objectStoreNames.length is 3
|
|
PASS connection4store1.indexNames.length is 3
|
|
|
|
PASS successfullyParsed is true
|
|
|
|
TEST COMPLETE
|
|
|