92 lines
2.7 KiB
Plaintext
92 lines
2.7 KiB
Plaintext
Test IndexedDB primary key ordering and readback from cursors.
|
|
|
|
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)
|
|
store = db.createObjectStore('store')
|
|
index = store.createIndex('index', 'indexKey')
|
|
|
|
populating store...
|
|
trans = db.transaction('store', 'readwrite')
|
|
store = trans.objectStore('store');
|
|
store.put({"indexKey":0,"count":0}, 'c')
|
|
store.put({"indexKey":0,"count":1}, 'b')
|
|
store.put({"indexKey":0,"count":2}, 'a')
|
|
store.put({"indexKey":0,"count":3}, 'C')
|
|
store.put({"indexKey":0,"count":4}, 'B')
|
|
store.put({"indexKey":0,"count":5}, 'A')
|
|
store.put({"indexKey":0,"count":6}, '2')
|
|
store.put({"indexKey":0,"count":7}, '1')
|
|
store.put({"indexKey":0,"count":8}, '0')
|
|
store.put({"indexKey":0,"count":9}, Infinity)
|
|
store.put({"indexKey":0,"count":10}, 2)
|
|
store.put({"indexKey":0,"count":11}, 1)
|
|
store.put({"indexKey":0,"count":12}, 0)
|
|
store.put({"indexKey":0,"count":13}, -1)
|
|
store.put({"indexKey":0,"count":14}, -2)
|
|
store.put({"indexKey":0,"count":15}, -Infinity)
|
|
|
|
iterating cursor...
|
|
trans = db.transaction('store', 'readonly')
|
|
store = trans.objectStore('store');
|
|
index = store.index('index');
|
|
cursorRequest = index.openCursor()
|
|
count = 0
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is -Infinity
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is -2
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is -1
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is 0
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is 1
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is 2
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is Infinity
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is '0'
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is '1'
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is '2'
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is 'A'
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is 'B'
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is 'C'
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is 'a'
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is 'b'
|
|
cursor = cursorRequest.result
|
|
PASS cursor.key is 0
|
|
PASS cursor.primaryKey is 'c'
|
|
PASS count is keys.length
|
|
PASS successfullyParsed is true
|
|
|
|
TEST COMPLETE
|
|
|