1 Test IndexedDB behavior when iterating backwards with and without NO_DUPLICATE
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "cursor-prev-no-duplicate.html"
7 indexedDB.deleteDatabase(dbname)
9 store = db.createObjectStore('store')
10 store.createIndex('index', 'sorted')
13 trans = db.transaction('store', 'readwrite')
14 store = trans.objectStore('store');
15 store.put({sorted: 3, value: 111}, 1)
16 store.put({sorted: 2, value: 222}, 2)
17 store.put({sorted: 1, value: 333}, 3)
18 store.put({sorted: 10, value: 444}, 17)
19 store.put({sorted: 10, value: 555}, 16)
20 store.put({sorted: 10, value: 666}, 15)
22 testFarRangeCursor: upper bound is well out of range, results always the same, whether open or closed
23 storeReq = store.openCursor(IDBKeyRange.upperBound(7, false), 'prev')
25 PASS cursor.value.value is 333
28 storeReq = store.openCursor(IDBKeyRange.upperBound(7, true), 'prev')
30 PASS cursor.value.value is 333
33 storeReq = index.openCursor(IDBKeyRange.upperBound(7, false), 'prev')
35 PASS cursor.value.value is 111
36 PASS cursor.primaryKey is 1
39 storeReq = index.openCursor(IDBKeyRange.upperBound(7, true), 'prev')
41 PASS cursor.value.value is 111
42 PASS cursor.primaryKey is 1
45 storeReq = index.openKeyCursor(IDBKeyRange.upperBound(7, false), 'prev')
47 PASS cursor.primaryKey is 1
50 storeReq = index.openKeyCursor(IDBKeyRange.upperBound(7, true), 'prev')
52 PASS cursor.primaryKey is 1
55 storeReq = store.openCursor(IDBKeyRange.upperBound(3, false), 'prev')
57 PASS cursor.value.value is 333
60 storeReq = store.openCursor(IDBKeyRange.upperBound(3, true), 'prev')
62 PASS cursor.value.value is 222
65 storeReq = index.openCursor(IDBKeyRange.upperBound(3, false), 'prev')
67 PASS cursor.value.value is 111
68 PASS cursor.primaryKey is 1
71 storeReq = index.openCursor(IDBKeyRange.upperBound(3, true), 'prev')
73 PASS cursor.value.value is 222
74 PASS cursor.primaryKey is 2
77 storeReq = index.openKeyCursor(IDBKeyRange.upperBound(3, false), 'prev')
79 PASS cursor.primaryKey is 1
82 storeReq = index.openKeyCursor(IDBKeyRange.upperBound(3, true), 'prev')
84 PASS cursor.primaryKey is 2
87 testNoDuplicate: there are 3 values, but we should return always the first one
88 storeReq = store.openCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
90 PASS cursor.value.value is 666
91 PASS cursor.primaryKey is 15
94 storeReq = index.openCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
96 PASS cursor.value.value is 666
97 PASS cursor.primaryKey is 15
100 storeReq = index.openKeyCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
101 PASS cursor.key is 10
102 PASS cursor.primaryKey is 15
105 PASS successfullyParsed is true