chromium/third_party/blink/web_tests/storage/indexeddb/cursor-value-expected.txt

Test IndexedDB's cursor value property.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

dbname = "cursor-value.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
db.createObjectStore('store')


testCursor():
transaction = db.transaction('store', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('store')
store.put({a: 1, b: 10}, 'key1')
store.put({a: 2, b: 20}, 'key2')
store.put({a: 3, b: 30}, 'key3')
store.put({a: 4, b: 40}, 'key4')
store.put({a: 5, b: 50}, 'key5')
request = store.openCursor()


----------
Value at index: 0
cursor = request.result
PASS cursor.key is expectedKey


Check expected values:
PASS cursor.value.a is expectedA
PASS cursor.value.b is expectedB
PASS cursor.value.foo is undefined


Modify values:
cursor.value.a = 3
delete cursor.value.b
cursor.value.foo = 'bar'


Ensure modifications are retained:
PASS cursor.value.a is 3
PASS cursor.value.b is undefined
PASS cursor.value.foo is 'bar'


Check object value survives gc
gc()
PASS cursor.value.a is 3
PASS cursor.value.b is undefined
PASS cursor.value.foo is 'bar'


Check object identity
localValueRef = cursor.value
PASS localValueRef is cursor.value


----------
Value at index: 1
cursor = request.result
PASS cursor.key is expectedKey


Check expected values:
PASS cursor.value.a is expectedA
PASS cursor.value.b is expectedB
PASS cursor.value.foo is undefined


Modify values:
cursor.value.a = 3
delete cursor.value.b
cursor.value.foo = 'bar'


Ensure modifications are retained:
PASS cursor.value.a is 3
PASS cursor.value.b is undefined
PASS cursor.value.foo is 'bar'


Check object value survives gc
gc()
PASS cursor.value.a is 3
PASS cursor.value.b is undefined
PASS cursor.value.foo is 'bar'


Check object identity
localValueRef = cursor.value
PASS localValueRef is cursor.value


----------
Value at index: 3
cursor = request.result
PASS cursor.key is expectedKey


Check expected values:
PASS cursor.value.a is expectedA
PASS cursor.value.b is expectedB
PASS cursor.value.foo is undefined


Modify values:
cursor.value.a = 3
delete cursor.value.b
cursor.value.foo = 'bar'


Ensure modifications are retained:
PASS cursor.value.a is 3
PASS cursor.value.b is undefined
PASS cursor.value.foo is 'bar'


Check object value survives gc
gc()
PASS cursor.value.a is 3
PASS cursor.value.b is undefined
PASS cursor.value.foo is 'bar'


Check object identity
localValueRef = cursor.value
PASS localValueRef is cursor.value


ensureModificationsNotPersisted():
transaction = db.transaction('store', 'readonly', {durability: 'relaxed'})
store = transaction.objectStore('store')
request = store.openCursor()
cursor = request.result
PASS cursor.key is 'key1'


Check expected values:
PASS cursor.value.a is 1
PASS cursor.value.b is 10
PASS cursor.value.foo is undefined
PASS successfullyParsed is true

TEST COMPLETE