blob: 45f096c32920ff768135acb32b362d8377dc7488 [file] [log] [blame]
Test IndexedDB's IDBObjectStore.count().
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('storeName', null)
adding 0 ... 99
verifying count without range
trans = db.transaction('storeName', 'readonly')
PASS trans is non-null.
store = trans.objectStore('storeName')
PASS store is non-null.
request = store.count()
PASS typeof request.result is "number"
PASS request.result is 100
verifying count with range
trans = db.transaction('storeName', 'readonly')
PASS trans is non-null.
store = trans.objectStore('storeName')
PASS store is non-null.
test = {"lower":0,"lowerOpen":false,"upper":99,"upperOpen":false,"expected":100}
request = store.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result is "number"
PASS request.result is 100
test = {"lower":0,"lowerOpen":true,"upper":99,"upperOpen":false,"expected":99}
request = store.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result is "number"
PASS request.result is 99
test = {"lower":0,"lowerOpen":false,"upper":99,"upperOpen":true,"expected":99}
request = store.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result is "number"
PASS request.result is 99
test = {"lower":0,"lowerOpen":true,"upper":99,"upperOpen":true,"expected":98}
request = store.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result is "number"
PASS request.result is 98
test = {"lower":0,"lowerOpen":false,"upper":100,"upperOpen":false,"expected":100}
request = store.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result is "number"
PASS request.result is 100
test = {"lower":0,"lowerOpen":false,"upper":100,"upperOpen":false,"expected":100}
request = store.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result is "number"
PASS request.result is 100
test = {"lower":10,"lowerOpen":false,"upper":100,"upperOpen":false,"expected":90}
request = store.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result is "number"
PASS request.result is 90
test = {"lower":0,"lowerOpen":false,"upper":0,"upperOpen":false,"expected":1}
request = store.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result is "number"
PASS request.result is 1
test = {"lower":500,"lowerOpen":false,"upper":500,"upperOpen":false,"expected":0}
request = store.count(IDBKeyRange.bound(test.lower, test.upper, test.lowerOpen, test.upperOpen))
PASS typeof request.result is "number"
PASS request.result is 0
verifying count with key
trans = db.transaction('storeName', 'readonly')
PASS trans is non-null.
store = trans.objectStore('storeName')
PASS store is non-null.
Expecting exception from store.count(NaN)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'count' on 'IDBObjectStore': The parameter is not a valid key.
Expecting exception from store.count({})
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'count' on 'IDBObjectStore': The parameter is not a valid key.
Expecting exception from store.count(/regex/)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'count' on 'IDBObjectStore': The parameter is not a valid key.
test = {"key":0,"expected":1}
request = store.count(test.key)
PASS typeof request.result is "number"
PASS request.result is 1
test = {"key":100,"expected":0}
request = store.count(test.key)
PASS typeof request.result is "number"
PASS request.result is 0
test = {"key":null,"expected":100}
request = store.count(test.key)
PASS typeof request.result is "number"
PASS request.result is 100
PASS successfullyParsed is true
TEST COMPLETE