blob: e156408cfabc347293fcb79773cf76b2bcea8679 [file] [log] [blame]
Test that IndexedDB's cursor key/primaryKey/value properties preserve mutations.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
dbname = "cursor-properties.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname, 1)
onUpgradeNeeded():
db = event.target.result
store = db.createObjectStore('store')
index = store.createIndex('index', 'id')
store.put({id: ['indexKey']}, ['primaryKey'])
onOpenSuccess():
db = event.target.result
trans = db.transaction('store')
store = trans.objectStore('store')
index = store.index('index')
request = index.openCursor()
onCursorSuccess():
cursor = event.target.result
PASS cursor is non-null.
PASS areArraysEqual(cursor.key, ['indexKey']) is true
PASS areArraysEqual(cursor.primaryKey, ['primaryKey']) is true
Check identity:
v = cursor.key
PASS v === cursor.key is true
Check read-only:
cursor.key = null
PASS v === cursor.key is true
Check mutability:
cursor.key.expando = 123
PASS cursor.key.expando is 123
Check identity:
v = cursor.primaryKey
PASS v === cursor.primaryKey is true
Check read-only:
cursor.primaryKey = null
PASS v === cursor.primaryKey is true
Check mutability:
cursor.primaryKey.expando = 123
PASS cursor.primaryKey.expando is 123
Check identity:
v = cursor.value
PASS v === cursor.value is true
Check read-only:
cursor.value = null
PASS v === cursor.value is true
Check mutability:
cursor.value.expando = 123
PASS cursor.value.expando is 123
PASS successfullyParsed is true
TEST COMPLETE