OLD | NEW |
1 Test IndexedDB: mutating records with a r/w cursor updates indexes on those reco
rds | 1 Test IndexedDB: mutating records with a r/w cursor updates indexes on those reco
rds |
2 | 2 |
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". | 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". |
4 | 4 |
5 | 5 |
6 firstValue = 'hi'; | 6 firstValue = 'hi'; |
7 secondValue = 'bye'; | 7 secondValue = 'bye'; |
8 objectStoreInfo = [ | 8 objectStoreInfo = [ |
9 { name: '1', options: {}, key: 1, | 9 { name: '1', options: {}, key: 1, |
10 entry: { data: firstValue } }, | 10 entry: { data: firstValue } }, |
11 { name: '2', options: { keyPath: 'foo' }, | 11 { name: '2', options: { keyPath: 'foo' }, |
12 entry: { foo: 1, data: firstValue } }, | 12 entry: { foo: 1, data: firstValue } }, |
13 { name: '3', options: { autoIncrement: true }, | 13 { name: '3', options: { autoIncrement: true }, |
14 entry: { data: firstValue } }, | 14 entry: { data: firstValue } }, |
15 { name: '4', options: { keyPath: 'foo', autoIncrement: true }, | 15 { name: '4', options: { keyPath: 'foo', autoIncrement: true }, |
16 entry: { data: firstValue } }, | 16 entry: { data: firstValue } }, |
17 ]; | 17 ]; |
18 i = 0; | 18 i = 0; |
19 | 19 |
20 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; | |
21 | |
22 dbname = "cursor-update-updates-indexes.html" | 20 dbname = "cursor-update-updates-indexes.html" |
23 indexedDB.deleteDatabase(dbname) | 21 indexedDB.deleteDatabase(dbname) |
24 info = objectStoreInfo[i]; | 22 info = objectStoreInfo[i]; |
25 indexedDB.open(dbname) | 23 indexedDB.open(dbname) |
26 setupObjectStoreAndCreateIndex(): | 24 setupObjectStoreAndCreateIndex(): |
27 db = event.target.result | 25 db = event.target.result |
28 objectStore = db.createObjectStore(info.name, info.options); | 26 objectStore = db.createObjectStore(info.name, info.options); |
29 index = objectStore.createIndex('data_index', 'data', { unique: false }); | 27 index = objectStore.createIndex('data_index', 'data', { unique: false }); |
30 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: tru
e }); | 28 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: tru
e }); |
31 request = objectStore.add(info.entry, info.key); | 29 request = objectStore.add(info.entry, info.key); |
32 trans = db.transaction(info.name, 'readwrite') | 30 trans = db.transaction(info.name, 'readwrite') |
33 trans.oncomplete = test | 31 trans.oncomplete = test |
34 objectStore = trans.objectStore(info.name) | 32 objectStore = trans.objectStore(info.name) |
35 index = objectStore.index('data_index') | 33 index = objectStore.index('data_index') |
36 uniqueIndex = objectStore.index('unique_data_index') | 34 uniqueIndex = objectStore.index('unique_data_index') |
37 request = objectStore.openCursor(); | 35 request = objectStore.openCursor(); |
38 cursor = request.result; | 36 cursor = request.result; |
39 value = cursor.value; | 37 value = cursor.value; |
40 value.data = secondValue; | 38 value.data = secondValue; |
41 request = cursor.update(value); | 39 request = cursor.update(value); |
42 request = index.get(secondValue); | 40 request = index.get(secondValue); |
43 PASS value.data is event.target.result.data | 41 PASS value.data is event.target.result.data |
44 request = uniqueIndex.get(secondValue); | 42 request = uniqueIndex.get(secondValue); |
45 PASS value.data is event.target.result.data | 43 PASS value.data is event.target.result.data |
46 i++; | 44 i++; |
47 db.close() | 45 db.close() |
48 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; | |
49 | |
50 dbname = "cursor-update-updates-indexes.html" | 46 dbname = "cursor-update-updates-indexes.html" |
51 indexedDB.deleteDatabase(dbname) | 47 indexedDB.deleteDatabase(dbname) |
52 info = objectStoreInfo[i]; | 48 info = objectStoreInfo[i]; |
53 indexedDB.open(dbname) | 49 indexedDB.open(dbname) |
54 setupObjectStoreAndCreateIndex(): | 50 setupObjectStoreAndCreateIndex(): |
55 db = event.target.result | 51 db = event.target.result |
56 objectStore = db.createObjectStore(info.name, info.options); | 52 objectStore = db.createObjectStore(info.name, info.options); |
57 index = objectStore.createIndex('data_index', 'data', { unique: false }); | 53 index = objectStore.createIndex('data_index', 'data', { unique: false }); |
58 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: tru
e }); | 54 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: tru
e }); |
59 request = objectStore.add(info.entry); | 55 request = objectStore.add(info.entry); |
60 trans = db.transaction(info.name, 'readwrite') | 56 trans = db.transaction(info.name, 'readwrite') |
61 trans.oncomplete = test | 57 trans.oncomplete = test |
62 objectStore = trans.objectStore(info.name) | 58 objectStore = trans.objectStore(info.name) |
63 index = objectStore.index('data_index') | 59 index = objectStore.index('data_index') |
64 uniqueIndex = objectStore.index('unique_data_index') | 60 uniqueIndex = objectStore.index('unique_data_index') |
65 request = objectStore.openCursor(); | 61 request = objectStore.openCursor(); |
66 cursor = request.result; | 62 cursor = request.result; |
67 value = cursor.value; | 63 value = cursor.value; |
68 value.data = secondValue; | 64 value.data = secondValue; |
69 request = cursor.update(value); | 65 request = cursor.update(value); |
70 request = index.get(secondValue); | 66 request = index.get(secondValue); |
71 PASS value.data is event.target.result.data | 67 PASS value.data is event.target.result.data |
72 request = uniqueIndex.get(secondValue); | 68 request = uniqueIndex.get(secondValue); |
73 PASS value.data is event.target.result.data | 69 PASS value.data is event.target.result.data |
74 i++; | 70 i++; |
75 db.close() | 71 db.close() |
76 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; | |
77 | |
78 dbname = "cursor-update-updates-indexes.html" | 72 dbname = "cursor-update-updates-indexes.html" |
79 indexedDB.deleteDatabase(dbname) | 73 indexedDB.deleteDatabase(dbname) |
80 info = objectStoreInfo[i]; | 74 info = objectStoreInfo[i]; |
81 indexedDB.open(dbname) | 75 indexedDB.open(dbname) |
82 setupObjectStoreAndCreateIndex(): | 76 setupObjectStoreAndCreateIndex(): |
83 db = event.target.result | 77 db = event.target.result |
84 objectStore = db.createObjectStore(info.name, info.options); | 78 objectStore = db.createObjectStore(info.name, info.options); |
85 index = objectStore.createIndex('data_index', 'data', { unique: false }); | 79 index = objectStore.createIndex('data_index', 'data', { unique: false }); |
86 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: tru
e }); | 80 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: tru
e }); |
87 request = objectStore.add(info.entry); | 81 request = objectStore.add(info.entry); |
88 trans = db.transaction(info.name, 'readwrite') | 82 trans = db.transaction(info.name, 'readwrite') |
89 trans.oncomplete = test | 83 trans.oncomplete = test |
90 objectStore = trans.objectStore(info.name) | 84 objectStore = trans.objectStore(info.name) |
91 index = objectStore.index('data_index') | 85 index = objectStore.index('data_index') |
92 uniqueIndex = objectStore.index('unique_data_index') | 86 uniqueIndex = objectStore.index('unique_data_index') |
93 request = objectStore.openCursor(); | 87 request = objectStore.openCursor(); |
94 cursor = request.result; | 88 cursor = request.result; |
95 value = cursor.value; | 89 value = cursor.value; |
96 value.data = secondValue; | 90 value.data = secondValue; |
97 request = cursor.update(value); | 91 request = cursor.update(value); |
98 request = index.get(secondValue); | 92 request = index.get(secondValue); |
99 PASS value.data is event.target.result.data | 93 PASS value.data is event.target.result.data |
100 request = uniqueIndex.get(secondValue); | 94 request = uniqueIndex.get(secondValue); |
101 PASS value.data is event.target.result.data | 95 PASS value.data is event.target.result.data |
102 i++; | 96 i++; |
103 db.close() | 97 db.close() |
104 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; | |
105 | |
106 dbname = "cursor-update-updates-indexes.html" | 98 dbname = "cursor-update-updates-indexes.html" |
107 indexedDB.deleteDatabase(dbname) | 99 indexedDB.deleteDatabase(dbname) |
108 info = objectStoreInfo[i]; | 100 info = objectStoreInfo[i]; |
109 indexedDB.open(dbname) | 101 indexedDB.open(dbname) |
110 setupObjectStoreAndCreateIndex(): | 102 setupObjectStoreAndCreateIndex(): |
111 db = event.target.result | 103 db = event.target.result |
112 objectStore = db.createObjectStore(info.name, info.options); | 104 objectStore = db.createObjectStore(info.name, info.options); |
113 index = objectStore.createIndex('data_index', 'data', { unique: false }); | 105 index = objectStore.createIndex('data_index', 'data', { unique: false }); |
114 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: tru
e }); | 106 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: tru
e }); |
115 request = objectStore.add(info.entry); | 107 request = objectStore.add(info.entry); |
(...skipping 10 matching lines...) Expand all Loading... |
126 request = index.get(secondValue); | 118 request = index.get(secondValue); |
127 PASS value.data is event.target.result.data | 119 PASS value.data is event.target.result.data |
128 request = uniqueIndex.get(secondValue); | 120 request = uniqueIndex.get(secondValue); |
129 PASS value.data is event.target.result.data | 121 PASS value.data is event.target.result.data |
130 i++; | 122 i++; |
131 db.close() | 123 db.close() |
132 PASS successfullyParsed is true | 124 PASS successfullyParsed is true |
133 | 125 |
134 TEST COMPLETE | 126 TEST COMPLETE |
135 | 127 |
OLD | NEW |