Home | History | Annotate | Download | only in indexeddb
      1 Test the basics of IndexedDB's IDBObjectStore.
      2 
      3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
      4 
      5 
      6 webkitIndexedDB.open('objectstore-basics')
      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('storeName', null)
     16 storeNames = db.objectStoreNames
     17 PASS store.name is "storeName"
     18 PASS store.keyPath is null
     19 PASS storeNames.contains('storeName') is true
     20 PASS storeNames.length is 1
     21 Ask for an index that doesn't exist:
     22 index = store.index('asdf')
     23 PASS Exception thrown.
     24 PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
     25 createIndex():
     26 index = store.createIndex('indexName', 'x', {unique: true})
     27 PASS index !== null is true
     28 PASS store.indexNames.contains('indexName') is true
     29 index = store.index('indexName')
     30 PASS index !== null is true
     31 Ask for an index that doesn't exist:
     32 index = store.index('asdf')
     33 PASS Exception thrown.
     34 PASS code is webkitIDBDatabaseException.NOT_FOUND_ERR
     35 db.setVersion("version fail")
     36 PASS db.version is "version fail"
     37 setVersionTrans = event.target.result
     38 PASS setVersionTrans !== null is true
     39 store = setVersionTrans.objectStore('storeName')
     40 index = store.createIndex('indexFail', 'x')
     41 PASS db.version is "new version"
     42 PASS store.indexNames is ['indexName']
     43 PASS store.indexNames.length is 1
     44 PASS store.indexNames.contains('') is false
     45 PASS store.indexNames.contains('indexFail') is false
     46 PASS store.indexNames.contains('indexName') is true
     47 PASS store.indexNames[0] is "indexName"
     48 PASS store.indexNames[1] is null
     49 PASS store.indexNames[100] is null
     50 PASS store.indexNames.item(1) is null
     51 PASS store.indexNames.item(100) is null
     52 transaction = db.transaction([], webkitIDBTransaction.READ_WRITE)
     53 store = transaction.objectStore('storeName')
     54 Try to insert data with a Date key:
     55 store.add({x: 'foo'}, testDate)
     56 Try to insert a value not handled by structured clone:
     57 store.add({x: 'bar', y: document.getElementById('console')}, 'bar')
     58 PASS Exception thrown
     59 PASS code is DOMException.NOT_SUPPORTED_ERR
     60 Try to insert data where key path yields a Date key:
     61 store.add({x: testDateB, y: 'value'}, 'key')
     62 addSuccess():
     63 PASS event.target.result is "key"
     64 event.target.source.add({x: 'foo'}, 'zzz')
     65 addAgainFailure():
     66 PASS event.target.errorCode is webkitIDBDatabaseException.UNKNOWN_ERR
     67 event.preventDefault()
     68 db.transaction([], webkitIDBTransaction.READ_WRITE)
     69 store = transaction.objectStore('storeName')
     70 store.add({x: 'othervalue'}, null)
     71 addWithNullKeyFailre():
     72 PASS event.target.errorCode is webkitIDBDatabaseException.DATA_ERR
     73 event.preventDefault()
     74 db.transaction([], webkitIDBTransaction.READ_WRITE)
     75 store = transaction.objectStore('storeName')
     76 store.add({x: null}, 'validkey')
     77 PASS event.cancelable is true
     78 addWithNullIndexFailure():
     79 PASS event.target.errorCode is webkitIDBDatabaseException.DATA_ERR
     80 event.preventDefault()
     81 db.transaction([], webkitIDBTransaction.READ_WRITE)
     82 store = transaction.objectStore('storeName')
     83 store.get('key')
     84 getSuccess():
     85 PASS event.target.result.y is "value"
     86 store = event.target.source
     87 store.get(testDate)
     88 getSuccessDateKey():
     89 PASS event.target.result.x is "foo"
     90 store.delete('key')
     91 removeSuccess():
     92 PASS event.target.result is null
     93 store = event.target.source
     94 Passing an invalid key into store.get().
     95 PASS Caught exception: Error: TYPE_MISMATCH_ERR: DOM Exception 17
     96 Passing an invalid key into store.delete().
     97 PASS Caught exception: Error: TYPE_MISMATCH_ERR: DOM Exception 17
     98 Passing an invalid key into store.add().
     99 PASS Caught exception: Error: TYPE_MISMATCH_ERR: DOM Exception 17
    100 Passing an invalid key into store.put().
    101 PASS Caught exception: Error: TYPE_MISMATCH_ERR: DOM Exception 17
    102 PASS successfullyParsed is true
    103 
    104 TEST COMPLETE
    105 
    106