Home | History | Annotate | Download | only in indexeddb
      1 Test IndexedDB's IDBObjectStore auto-increment feature.
      2 
      3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
      4 
      5 
      6 webkitIndexedDB.open('objectstore-autoincrement')
      7 openSuccess():
      8 db = event.target.result
      9 db.setVersion('new version')
     10 setVersionSuccess():
     11 trans = event.target.result
     12 PASS trans !== null is true
     13 Deleted all object stores.
     14 createObjectStore():
     15 store = db.createObjectStore('StoreWithKeyPath', {keyPath: 'id', autoIncrement: true})
     16 db.createObjectStore('StoreWithAutoIncrement', {autoIncrement: true})
     17 db.createObjectStore('PlainOldStore', {autoIncrement: false})
     18 storeNames = db.objectStoreNames
     19 PASS store.name is "StoreWithKeyPath"
     20 PASS store.keyPath is 'id'
     21 PASS storeNames.contains('StoreWithKeyPath') is true
     22 PASS storeNames.contains('StoreWithAutoIncrement') is true
     23 PASS storeNames.contains('PlainOldStore') is true
     24 PASS storeNames.length is 3
     25 setVersionCompleted():
     26 trans = db.transaction([], webkitIDBTransaction.READ_WRITE)
     27 store = trans.objectStore('StoreWithKeyPath')
     28 Insert into object store with auto increment and key path, with key in the object.
     29 store.add({name: 'Jeffersson', number: '7010', id: 3})
     30 addJefferssonSuccess():
     31 PASS event.target.result is 3
     32 Insert into object store with auto increment and key path, without key in the object.
     33 store.add({name: 'Lincoln', number: '7012'})
     34 addLincolnWithInjectKeySuccess():
     35 PASS event.target.result is 4
     36 store.get(4)
     37 getLincolnAfterInjectedKeySuccess():
     38 PASS event.target.result.name is "Lincoln"
     39 PASS event.target.result.number is "7012"
     40 PASS event.target.result.id is 4
     41 store = trans.objectStore('StoreWithAutoIncrement')
     42 Insert into object store with key gen using explicit key
     43 store.add({name: 'Lincoln', number: '7012'}, 5)
     44 addLincolnWithExplicitKeySuccess():
     45 PASS event.target.result is 5
     46 store.get(5)
     47 getLincolnSuccess():
     48 PASS event.target.result.name is "Lincoln"
     49 PASS event.target.result.number is "7012"
     50 store.put({name: 'Abraham', number: '2107'})
     51 putAbrahamSuccess():
     52 PASS event.target.result is 6
     53 store.get(6)
     54 getAbrahamSuccess():
     55 PASS event.target.result.name is "Abraham"
     56 PASS event.target.result.number is "2107"
     57 store = trans.objectStore('PlainOldStore')
     58 Try adding with no key to object store without auto increment.
     59 store.add({name: 'Adam'})
     60 addAdamError():
     61 PASS event.target.errorCode is webkitIDBDatabaseException.DATA_ERR
     62 event.preventDefault()
     63 store.add({name: 'Adam'}, 1)
     64 addAdamSuccess():
     65 PASS event.target.result is 1
     66 PASS successfullyParsed is true
     67 
     68 TEST COMPLETE
     69 
     70