blob: 4ab6266fc7f836a9dccc7acfe0fd1ce6263c243a [file] [log] [blame]
[Worker] Test the basics of IndexedDB's IDBObjectStore.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Starting worker: resources/objectstore-basics.js
[Worker] indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
[Worker]
[Worker] indexedDB.deleteDatabase(dbname)
[Worker] indexedDB.open(dbname)
[Worker]
[Worker] prepareDatabase():
[Worker] store = db.createObjectStore('storeName', null)
[Worker] storeNames = db.objectStoreNames
PASS [Worker] 'name' in store is true
PASS [Worker] 'keyPath' in store is true
PASS [Worker] 'indexNames' in store is true
PASS [Worker] 'transaction' in store is true
PASS [Worker] 'autoIncrement' in store is true
PASS [Worker] 'put' in store is true
PASS [Worker] typeof store.put is "function"
PASS [Worker] 'add' in store is true
PASS [Worker] typeof store.add is "function"
PASS [Worker] 'delete' in store is true
PASS [Worker] typeof store.delete is "function"
PASS [Worker] 'get' in store is true
PASS [Worker] typeof store.get is "function"
PASS [Worker] 'clear' in store is true
PASS [Worker] typeof store.clear is "function"
PASS [Worker] 'openCursor' in store is true
PASS [Worker] typeof store.openCursor is "function"
PASS [Worker] 'createIndex' in store is true
PASS [Worker] typeof store.createIndex is "function"
PASS [Worker] 'index' in store is true
PASS [Worker] typeof store.index is "function"
PASS [Worker] 'deleteIndex' in store is true
PASS [Worker] typeof store.deleteIndex is "function"
PASS [Worker] 'count' in store is true
PASS [Worker] typeof store.count is "function"
PASS [Worker] store.name is "storeName"
PASS [Worker] store.keyPath is null
PASS [Worker] store.autoIncrement is false
PASS [Worker] storeNames.contains('storeName') is true
PASS [Worker] storeNames.length is 1
PASS [Worker] db.createObjectStore('storeWithKeyPath', {keyPath: 'path'}).keyPath is "path"
PASS [Worker] db.createObjectStore('storeWithKeyGenerator', {autoIncrement: true}).autoIncrement is true
[Worker] Ask for an index that doesn't exist:
[Worker] Expecting exception from store.index('asdf')
PASS [Worker] Exception was thrown.
PASS [Worker] code is DOMException.NOT_FOUND_ERR
PASS [Worker] ename is 'NotFoundError'
[Worker] Exception message: Failed to execute 'index' on 'IDBObjectStore': The specified index was not found.
[Worker] createIndex():
[Worker] index = store.createIndex('indexName', 'x', {unique: true})
PASS [Worker] index is non-null.
PASS [Worker] store.indexNames.contains('indexName') is true
[Worker] index = store.index('indexName')
PASS [Worker] index is non-null.
[Worker] Ask for an index that doesn't exist:
[Worker] Expecting exception from store.index('asdf')
PASS [Worker] Exception was thrown.
PASS [Worker] code is DOMException.NOT_FOUND_ERR
PASS [Worker] ename is 'NotFoundError'
[Worker] Exception message: Failed to execute 'index' on 'IDBObjectStore': The specified index was not found.
[Worker] indexedDB.open(dbname, 2)
[Worker] db.close()
PASS [Worker] db.version is 2
[Worker] setVersionTrans = event.target.transaction
PASS [Worker] setVersionTrans is non-null.
[Worker] store = setVersionTrans.objectStore('storeName')
[Worker] index = store.createIndex('indexFail', 'x')
PASS [Worker] db.version is 1
PASS [Worker] store.transaction is setVersionTrans
PASS [Worker] store.indexNames is ['indexName']
PASS [Worker] store.indexNames.length is 1
PASS [Worker] store.indexNames.contains('') is false
PASS [Worker] store.indexNames.contains('indexFail') is false
PASS [Worker] store.indexNames.contains('indexName') is true
PASS [Worker] store.indexNames[0] is "indexName"
PASS [Worker] store.indexNames[1] is undefined.
PASS [Worker] store.indexNames[100] is undefined.
PASS [Worker] store.indexNames.item(1) is null
PASS [Worker] store.indexNames.item(100) is null
[Worker]
[Worker] openAgain():
[Worker] indexedDB.open(dbname)
[Worker]
[Worker] addData():
[Worker] db = event.target.result
[Worker] transaction = db.transaction(['storeName'], 'readwrite')
[Worker] store = transaction.objectStore('storeName')
[Worker] Try to insert data with a Date key:
[Worker] store.add({x: 'foo'}, testDate)
[Worker] Try to insert a value not handled by structured clone:
[Worker] Expecting exception from store.add({x: 'bar', y: self}, 'bar')
PASS [Worker] Exception was thrown.
PASS [Worker] code is DOMException.DATA_CLONE_ERR
[Worker] Exception message: The object can not be cloned.
[Worker] Try to insert data where key path yields a Date key:
[Worker] store.add({x: testDateB, y: 'value'}, 'key')
[Worker] addSuccess():
PASS [Worker] event.target.result is "key"
[Worker] event.target.source.add({x: 'foo'}, 'zzz')
[Worker] addAgainFailure():
PASS [Worker] event.target.error.name is 'ConstraintError'
[Worker] event.preventDefault()
[Worker] db.transaction(['storeName'], 'readwrite')
[Worker] store = transaction.objectStore('storeName')
[Worker] store.add({x: 'somevalue'}, 'somekey')
[Worker] Expecting exception from store.add({x: 'othervalue'}, null)
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: The parameter is not a valid key.
[Worker] db.transaction(['storeName'], 'readwrite')
[Worker] store = transaction.objectStore('storeName')
[Worker] Ensure invalid key pointed at by index keyPath is ignored
[Worker] store.add({x: null}, 'validkey')
[Worker] db.transaction(['storeName'], 'readwrite')
[Worker] store = transaction.objectStore('storeName')
[Worker] store.get('key')
[Worker] getSuccess():
PASS [Worker] event.target.result.y is "value"
[Worker] store = event.target.source
[Worker] store.get(testDate)
[Worker] getSuccessDateKey():
PASS [Worker] event.target.result.x is "foo"
[Worker] store.delete('key')
[Worker] removeSuccess():
PASS [Worker] event.target.result is undefined
[Worker] store.delete('key')
[Worker] removeSuccessButNotThere():
PASS [Worker] event.target.result is undefined
[Worker] store = event.target.source
[Worker] Passing an invalid key into store.get().
[Worker] Expecting exception from store.get({})
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to execute 'get' on 'IDBObjectStore': The parameter is not a valid key.
[Worker] Passing an invalid key into store.delete().
[Worker] Expecting exception from store.delete({})
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key.
[Worker] Passing an invalid key into store.add().
[Worker] Expecting exception from store.add(null, {})
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: The parameter is not a valid key.
[Worker] Passing an invalid key into store.put().
[Worker] Expecting exception from store.put(null, {})
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: The parameter is not a valid key.
[Worker]
[Worker] testPreConditions():
[Worker] indexedDB.open(dbname, 3)
[Worker]
[Worker] upgradeNeeded():
[Worker] storeWithInLineKeys = db.createObjectStore('storeWithInLineKeys', {keyPath: 'key'})
[Worker] storeWithOutOfLineKeys = db.createObjectStore('storeWithOutIOfLineKeys')
[Worker] storeWithIndex = db.createObjectStore('storeWithIndex')
[Worker] index = storeWithIndex.createIndex('indexName', 'indexKey')
[Worker]
[Worker] IDBObjectStore.put()
[Worker] The object store uses in-line keys and the key parameter was provided.
[Worker] Expecting exception from storeWithInLineKeys.put({key: 1}, 'key')
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: The object store uses in-line keys and the key parameter was provided.
[Worker] The object store uses out-of-line keys and has no key generator and the key parameter was not provided.
[Worker] Expecting exception from storeWithOutOfLineKeys.put({})
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: The object store uses out-of-line keys and has no key generator and the key parameter was not provided.
[Worker] The object store uses in-line keys and the result of evaluating the object store's key path yields a value and that value is not a valid key.
[Worker] Expecting exception from storeWithInLineKeys.put({key: null})
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: Evaluating the object store's key path yielded a value that is not a valid key.
[Worker] The object store uses in-line keys but no key generator and the result of evaluating the object store's key path does not yield a value.
[Worker] Expecting exception from storeWithInLineKeys.put({})
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value.
[Worker] The key parameter was provided but does not contain a valid key.
[Worker] Expecting exception from storeWithOutOfLineKeys.put({}, null)
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: The parameter is not a valid key.
[Worker]
[Worker] IDBObjectStore.add()
[Worker] The object store uses in-line keys and the key parameter was provided.
[Worker] Expecting exception from storeWithInLineKeys.add({key: 1}, 'key')
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: The object store uses in-line keys and the key parameter was provided.
[Worker] The object store uses out-of-line keys and has no key generator and the key parameter was not provided.
[Worker] Expecting exception from storeWithOutOfLineKeys.add({})
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: The object store uses out-of-line keys and has no key generator and the key parameter was not provided.
[Worker] The object store uses in-line keys and the result of evaluating the object store's key path yields a value and that value is not a valid key.
[Worker] Expecting exception from storeWithInLineKeys.add({key: null})
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: Evaluating the object store's key path yielded a value that is not a valid key.
[Worker] The object store uses in-line keys but no key generator and the result of evaluating the object store's key path does not yield a value.
[Worker] Expecting exception from storeWithInLineKeys.add({})
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: Evaluating the object store's key path did not yield a value.
[Worker] The key parameter was provided but does not contain a valid key.
[Worker] Expecting exception from storeWithOutOfLineKeys.add({}, null)
PASS [Worker] Exception was thrown.
PASS [Worker] code is 0
PASS [Worker] ename is 'DataError'
[Worker] Exception message: Failed to store record in an IDBObjectStore: The parameter is not a valid key.
PASS successfullyParsed is true
TEST COMPLETE