blob: 23be0fde9c04ce9393e1ad7c31d49c3f0826f912 [file] [log] [blame]
Test IndexedDB keyPath edge cases
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
dbname = "keypath-edges.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
db.createObjectStore('store-with-path', {keyPath: 'foo'})
db.createObjectStore('store-with-path-and-generator', {keyPath: 'foo', autoIncrement: true})
testKeyPaths():
transaction = db.transaction(['store-with-path'], 'readwrite')
store = transaction.objectStore('store-with-path')
Key path doesn't resolve to a value; should yield null, should throw DATA_ERR
Expecting exception from store.put(null)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': Evaluating the object store's key path did not yield a value.
Key path doesn't resolve to a value; should yield null, should throw DATA_ERR
Expecting exception from store.put({})
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': Evaluating the object store's key path did not yield a value.
Key path resolves to a value that is invalid key; should yield 'invalid' key, should throw DATA_ERR
Expecting exception from store.put({foo: null})
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': Evaluating the object store's key path yielded a value that is not a valid key.
Key path resolves to a value that is valid key; should yield 'string' key, should succeed
store.put({foo: 'zoo'})
PASS store.put succeeded
testKeyPathsAndGenerator():
transaction = db.transaction(['store-with-path-and-generator'], 'readwrite')
store = transaction.objectStore('store-with-path-and-generator')
Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception
Expecting exception from store.put(null)
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': A generated key could not be inserted into the value.
Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception
Expecting exception from store.put('string')
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': A generated key could not be inserted into the value.
Key path doesn't resolve to a value; should yield null, key should be generated, put request should succeed
store.put({})
PASS store.put succeeded
Key path resolves to a value that is invalid key; should yield 'invalid' key, should throw DATA_ERR
Expecting exception from store.put({foo: null})
PASS Exception was thrown.
PASS code is 0
PASS ename is 'DataError'
Exception message: Failed to execute 'put' on 'IDBObjectStore': Evaluating the object store's key path yielded a value that is not a valid key.
Key path resolves to a value that is valid key; should yield 'string' key, should succeed
store.put({foo: 'zoo'})
PASS store.put succeeded
PASS successfullyParsed is true
TEST COMPLETE