blob: 18e02bdb80d89f99232e8722584bf306df0e3c9b [file] [log] [blame]
Test IndexedDB Array-type keyPaths
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-arrays.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
store = db.createObjectStore('store', {keyPath: ['a', 'b']})
store.createIndex('index', ['c', 'd'])
Expecting exception from db.createObjectStore('store-with-generator', {keyPath: ['a', 'b'], autoIncrement: true})
PASS Exception was thrown.
PASS code is DOMException.INVALID_ACCESS_ERR
Expecting exception from store.createIndex('index-multientry', ['e', 'f'], {multiEntry: true})
PASS Exception was thrown.
PASS code is DOMException.INVALID_ACCESS_ERR
Empty arrays are not valid key paths:
Expecting exception from db.createObjectStore('store-keypath-empty-array', {keyPath: []})
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
Expecting exception from store.createIndex('index-keypath-empty-array', [])
PASS Exception was thrown.
PASS code is DOMException.SYNTAX_ERR
testKeyPaths():
transaction = db.transaction(['store'], 'readwrite')
store = transaction.objectStore('store')
index = store.index('index')
request = store.put({a: 1, b: 2, c: 3, d: 4})
request = store.openCursor()
cursor = request.result
PASS cursor is non-null.
PASS JSON.stringify(cursor.key) is "[1,2]"
request = index.openCursor()
cursor = request.result
PASS cursor is non-null.
PASS JSON.stringify(cursor.primaryKey) is "[1,2]"
PASS JSON.stringify(cursor.key) is "[3,4]"
PASS successfullyParsed is true
TEST COMPLETE