blob: 8624470c5e8c7ff12a2eacaa5edaf5ab43e422a0 [file] [log] [blame]
Test IndexedDB keyPath edge cases
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
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: DataError: DOM IDBDatabase Exception 0
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: DataError: DOM IDBDatabase Exception 0
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: DataError: DOM IDBDatabase Exception 0
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: DataError: DOM IDBDatabase Exception 0
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: DataError: DOM IDBDatabase Exception 0
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: DataError: DOM IDBDatabase Exception 0
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