| Test IndexedDB's IDBIndex.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) |
| store.createIndex('indexName', '') |
| PASS store.indexNames.contains('indexName') is true |
| 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. |
| index = store.index('indexName') |
| PASS index is non-null. |
| request = index.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. |
| index = trans.objectStore('storeName').index('indexName') |
| PASS index is non-null. |
| |
| test = {"lower":0,"lowerOpen":false,"upper":99,"upperOpen":false,"expected":100} |
| request = index.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 = index.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 = index.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 = index.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 = index.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 = index.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 = index.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 = index.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 = index.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. |
| index = trans.objectStore('storeName').index('indexName') |
| PASS index is non-null. |
| Expecting exception from index.count(NaN) |
| PASS Exception was thrown. |
| PASS code is 0 |
| PASS ename is 'DataError' |
| Exception message: Failed to execute 'count' on 'IDBIndex': The parameter is not a valid key. |
| Expecting exception from index.count({}) |
| PASS Exception was thrown. |
| PASS code is 0 |
| PASS ename is 'DataError' |
| Exception message: Failed to execute 'count' on 'IDBIndex': The parameter is not a valid key. |
| Expecting exception from index.count(/regex/) |
| PASS Exception was thrown. |
| PASS code is 0 |
| PASS ename is 'DataError' |
| Exception message: Failed to execute 'count' on 'IDBIndex': The parameter is not a valid key. |
| |
| test = {"key":0,"expected":1} |
| request = index.count(test.key) |
| PASS typeof request.result is "number" |
| PASS request.result is 1 |
| |
| test = {"key":100,"expected":0} |
| request = index.count(test.key) |
| PASS typeof request.result is "number" |
| PASS request.result is 0 |
| |
| test = {"key":null,"expected":100} |
| request = index.count(test.key) |
| PASS typeof request.result is "number" |
| PASS request.result is 100 |
| PASS successfullyParsed is true |
| |
| TEST COMPLETE |
| |