| Test the basics of IndexedDB's webkitIDBIndex. |
| |
| 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) |
| |
| prepareDatabase(): |
| db.createObjectStore('storeName', null) |
| store.createIndex('indexName', 'x') |
| store.createIndex('indexName2', 'y', {unique: false}) |
| store.createIndex('zIndex', 'z', {unique: true}) |
| PASS store.createIndex('index4', 'path', undefined) did not throw exception. |
| PASS indexObject2.unique is false |
| PASS indexObject3.unique is true |
| Expecting TypeError exception from store.createIndex('failureIndex', 'zzz', true) |
| PASS Exception was thrown. |
| PASS store.createIndex('failureIndex', 'zzz', true) threw TypeError: Type error |
| Expecting TypeError exception from store.createIndex('failureIndex', 'zzz', 'string') |
| PASS Exception was thrown. |
| PASS store.createIndex('failureIndex', 'zzz', 'string') threw TypeError: Type error |
| PASS 'name' in indexObject is true |
| PASS indexObject.name is "indexName" |
| PASS 'objectStore' in indexObject is true |
| PASS indexObject.objectStore.name is "storeName" |
| PASS 'keyPath' in indexObject is true |
| PASS indexObject.keyPath is "x" |
| PASS 'unique' in indexObject is true |
| PASS 'multiEntry' in indexObject is true |
| PASS indexObject.unique is false |
| PASS indexObject.multiEntry is false |
| PASS 'openKeyCursor' in indexObject is true |
| PASS typeof indexObject.openKeyCursor is "function" |
| PASS 'openCursor' in indexObject is true |
| PASS typeof indexObject.openCursor is "function" |
| PASS 'getKey' in indexObject is true |
| PASS typeof indexObject.getKey is "function" |
| PASS 'get' in indexObject is true |
| PASS typeof indexObject.get is "function" |
| PASS 'count' in indexObject is true |
| PASS typeof indexObject.count is "function" |
| store.add({x: 'value', y: 'zzz', z: 2.72}, 'key') |
| event.target.source.add({x: 'value2', y: 'zzz2', z: 2.71, foobar: 12}, 'key2') |
| store.createIndex('indexWhileAddIsInFlight', 'x') |
| store.createIndex('indexWithWeirdKeyPath', 'foobar') |
| Add data which doesn't have a key in the z index. |
| event.target.source.add({x: 'value3', y: '456'}, 'key3') |
| Add data which has invalid key for y index, no key for the z index. |
| event.target.source.add({x: 'value4', y: null}, 'key4') |
| indexObject.getKey('value') |
| PASS event.target.result is "key" |
| indexObject2.getKey('zzz') |
| PASS event.target.result is "key" |
| indexObject3.get(2.71) |
| PASS event.target.result.x is "value2" |
| indexObject.get('value') |
| PASS event.target.result.x is "value" |
| PASS event.target.result.y is "zzz" |
| indexObject.getKey('does not exist') |
| PASS event.target.result is undefined |
| indexObject.get('does not exist') |
| PASS event.target.result is undefined |
| indexObject4.getKey('value2') |
| PASS event.target.result is "key2" |
| |
| Verify that specifying an invalid direction raises an exception: |
| Expecting TypeError exception from indexObject.openKeyCursor(0, 'invalid-direction') |
| PASS Exception was thrown. |
| PASS indexObject.openKeyCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openKeyCursor must be one of: "next", "nextunique", "prev", "prevunique" |
| |
| indexObject.openKeyCursor() |
| PASS event.target.source is indexObject |
| PASS event.target.result is non-null. |
| PASS event.target.result.key is "value" |
| PASS event.target.result.primaryKey is "key" |
| event.target.result.continue() |
| PASS event.target.result is non-null. |
| PASS event.target.result.key is "value2" |
| PASS event.target.result.primaryKey is "key2" |
| event.target.result.continue() |
| PASS event.target.result is non-null. |
| PASS event.target.result.key is "value3" |
| PASS event.target.result.primaryKey is "key3" |
| event.target.result.continue() |
| PASS event.target.result is non-null. |
| PASS event.target.result.key is "value4" |
| PASS event.target.result.primaryKey is "key4" |
| event.target.result.continue() |
| PASS event.target.result is null |
| |
| Verify that specifying an invalid direction raises an exception: |
| Expecting TypeError exception from indexObject.openCursor(0, 'invalid-direction') |
| PASS Exception was thrown. |
| PASS indexObject.openCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openCursor must be one of: "next", "nextunique", "prev", "prevunique" |
| |
| indexObject.openCursor() |
| PASS event.target.source is indexObject |
| PASS event.target.result is non-null. |
| PASS event.target.result.key is "value" |
| PASS event.target.result.value.x is "value" |
| PASS event.target.result.value.y is "zzz" |
| event.target.result.continue() |
| PASS event.target.result is non-null. |
| PASS event.target.result.key is "value2" |
| PASS event.target.result.value.x is "value2" |
| PASS event.target.result.value.y is "zzz2" |
| event.target.result.continue() |
| PASS event.target.result is non-null. |
| PASS event.target.result.key is "value3" |
| PASS event.target.result.value.x is "value3" |
| PASS event.target.result.value.y is "456" |
| event.target.result.continue() |
| PASS event.target.result is non-null. |
| PASS event.target.result.key is "value4" |
| PASS event.target.result.value.x is "value4" |
| PASS event.target.result.value.y is null |
| event.target.result.continue() |
| PASS event.target.result is null |
| request = indexObject.count() |
| PASS event.target.result is 4 |
| request = indexObject2.count() |
| PASS event.target.result is 3 |
| request = indexObject3.count() |
| PASS event.target.result is 2 |
| Passing an invalid key into indexObject.get({}). |
| Expecting exception from indexObject.get({}) |
| PASS Exception was thrown. |
| PASS code is 0 |
| PASS ename is 'DataError' |
| Exception message: Failed to execute 'get' on 'IDBIndex': The parameter is not a valid key. |
| Passing an invalid key into indexObject.getKey({}). |
| Expecting exception from indexObject.getKey({}) |
| PASS Exception was thrown. |
| PASS code is 0 |
| PASS ename is 'DataError' |
| Exception message: Failed to execute 'getKey' on 'IDBIndex': The parameter is not a valid key. |
| PASS successfullyParsed is true |
| |
| TEST COMPLETE |
| |