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