| Test IndexedDB's putting and getting values in an object store |
| |
| 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) |
| testString = { key: 0, value: 'testString' }; |
| testInt = { key: 1, value: 1002 }; |
| objectStore = db.createObjectStore('Objects', { autoIncrement: false }); |
| request = objectStore.add(testString.value, testString.key); |
| PASS event.target.result is testString.key |
| request = objectStore.get(testString.key); |
| PASS event.target.result is testString.value |
| request = objectStore.add(testInt.value, testInt.key); |
| PASS event.target.result is testInt.key |
| request = objectStore.get(testInt.key); |
| PASS event.target.result is testInt.value |
| objectStoreAutoIncrement = db.createObjectStore('AutoIncremented Objects', { autoIncrement: true }); |
| request = objectStoreAutoIncrement.add(testString.value); |
| testString.key = event.target.result; |
| request = objectStoreAutoIncrement.get(testString.key); |
| PASS event.target.result is testString.value |
| request = objectStoreAutoIncrement.add(testInt.value); |
| testInt.key = event.target.result; |
| request = objectStoreAutoIncrement.get(testInt.key); |
| PASS event.target.result is testInt.value |
| PASS successfullyParsed is true |
| |
| TEST COMPLETE |
| |