1 Test IndexedDB's cursor value property.
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "cursor-value.html"
7 indexedDB.deleteDatabase(dbname)
9 db.createObjectStore('store')
12 transaction = db.transaction('store', 'readwrite')
13 store = transaction.objectStore('store')
14 store.put({a: 1, b: 10}, 'key1')
15 store.put({a: 2, b: 20}, 'key2')
16 store.put({a: 3, b: 30}, 'key3')
17 store.put({a: 4, b: 40}, 'key4')
18 store.put({a: 5, b: 50}, 'key5')
19 request = store.openCursor()
23 cursor = request.result
24 PASS cursor.key is expectedKey
26 Check expected values:
27 PASS cursor.value.a is expectedA
28 PASS cursor.value.b is expectedB
29 PASS cursor.value.foo is undefined
34 cursor.value.foo = 'bar'
36 Ensure modifications are retained:
37 PASS cursor.value.a is 3
38 PASS cursor.value.b is undefined
39 PASS cursor.value.foo is 'bar'
41 Check object value survives gc
43 PASS cursor.value.a is 3
44 PASS cursor.value.b is undefined
45 PASS cursor.value.foo is 'bar'
48 localValueRef = cursor.value
49 PASS localValueRef is cursor.value
53 cursor = request.result
54 PASS cursor.key is expectedKey
56 Check expected values:
57 PASS cursor.value.a is expectedA
58 PASS cursor.value.b is expectedB
59 PASS cursor.value.foo is undefined
64 cursor.value.foo = 'bar'
66 Ensure modifications are retained:
67 PASS cursor.value.a is 3
68 PASS cursor.value.b is undefined
69 PASS cursor.value.foo is 'bar'
71 Check object value survives gc
73 PASS cursor.value.a is 3
74 PASS cursor.value.b is undefined
75 PASS cursor.value.foo is 'bar'
78 localValueRef = cursor.value
79 PASS localValueRef is cursor.value
83 cursor = request.result
84 PASS cursor.key is expectedKey
86 Check expected values:
87 PASS cursor.value.a is expectedA
88 PASS cursor.value.b is expectedB
89 PASS cursor.value.foo is undefined
94 cursor.value.foo = 'bar'
96 Ensure modifications are retained:
97 PASS cursor.value.a is 3
98 PASS cursor.value.b is undefined
99 PASS cursor.value.foo is 'bar'
101 Check object value survives gc
103 PASS cursor.value.a is 3
104 PASS cursor.value.b is undefined
105 PASS cursor.value.foo is 'bar'
107 Check object identity
108 localValueRef = cursor.value
109 PASS localValueRef is cursor.value
111 ensureModificationsNotPersisted():
112 transaction = db.transaction('store', 'readonly')
113 store = transaction.objectStore('store')
114 request = store.openCursor()
115 cursor = request.result
116 PASS cursor.key is 'key1'
118 Check expected values:
119 PASS cursor.value.a is 1
120 PASS cursor.value.b is 10
121 PASS cursor.value.foo is undefined
122 PASS successfullyParsed is true