OLD | NEW |
1 Test IndexedDB indexes against autoincrementing keys | 1 Test IndexedDB indexes against autoincrementing keys |
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 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; | |
7 | |
8 dbname = "autoincrement-indexes.html" | 6 dbname = "autoincrement-indexes.html" |
9 indexedDB.deleteDatabase(dbname) | 7 indexedDB.deleteDatabase(dbname) |
10 indexedDB.open(dbname) | 8 indexedDB.open(dbname) |
11 objectStore = db.createObjectStore('autoincrement-id', { keyPath: 'id', autoIncr
ement: true }); | 9 objectStore = db.createObjectStore('autoincrement-id', { keyPath: 'id', autoIncr
ement: true }); |
12 objectStore.createIndex('first', 'first'); | 10 objectStore.createIndex('first', 'first'); |
13 objectStore.createIndex('second', 'second'); | 11 objectStore.createIndex('second', 'second'); |
14 objectStore.createIndex('third', 'third'); | 12 objectStore.createIndex('third', 'third'); |
15 data = { first: 'foo', second: 'foo', third: 'foo' }; | 13 data = { first: 'foo', second: 'foo', third: 'foo' }; |
16 request = objectStore.add(data); | 14 request = objectStore.add(data); |
17 key = event.target.result; | 15 key = event.target.result; |
18 PASS key == null is false | 16 PASS key == null is false |
19 expected key is 1 | 17 expected key is 1 |
20 objectStore = db.transaction('autoincrement-id').objectStore('autoincrement-id')
; | 18 objectStore = db.transaction('autoincrement-id').objectStore('autoincrement-id')
; |
21 first = objectStore.index('first'); | 19 first = objectStore.index('first'); |
22 request = first.get('foo'); | 20 request = first.get('foo'); |
23 PASS event.target.result.id is key | 21 PASS event.target.result.id is key |
24 second = objectStore.index('second'); | 22 second = objectStore.index('second'); |
25 request = second.get('foo'); | 23 request = second.get('foo'); |
26 PASS event.target.result.id is key | 24 PASS event.target.result.id is key |
27 third = objectStore.index('third'); | 25 third = objectStore.index('third'); |
28 request = third.get('foo'); | 26 request = third.get('foo'); |
29 PASS event.target.result.id is key | 27 PASS event.target.result.id is key |
30 PASS successfullyParsed is true | 28 PASS successfullyParsed is true |
31 | 29 |
32 TEST COMPLETE | 30 TEST COMPLETE |
33 | 31 |
OLD | NEW |