OLD | NEW |
1 Test IndexedDB Array-type keyPaths | 1 Test IndexedDB Array-type keyPaths |
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; | 6 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; |
7 | 7 |
8 dbname = "keypath-arrays.html" | 8 dbname = "keypath-arrays.html" |
9 indexedDB.deleteDatabase(dbname) | 9 indexedDB.deleteDatabase(dbname) |
10 indexedDB.open(dbname) | 10 indexedDB.open(dbname) |
11 store = db.createObjectStore('store', {keyPath: ['a', 'b']}) | 11 store = db.createObjectStore('store', {keyPath: ['a', 'b']}) |
12 store.createIndex('index', ['c', 'd']) | 12 store.createIndex('index', ['c', 'd']) |
13 Expecting exception from db.createObjectStore('store-with-generator', {keyPath:
['a', 'b'], autoIncrement: true}) | 13 Expecting exception from db.createObjectStore('store-with-generator', {keyPath:
['a', 'b'], autoIncrement: true}) |
14 PASS Exception was thrown. | 14 PASS Exception was thrown. |
15 PASS code is DOMException.INVALID_ACCESS_ERR | 15 PASS code is DOMException.INVALID_ACCESS_ERR |
16 Exception message: The autoIncrement option was set but the keyPath option was e
mpty or an array. | 16 Exception message: Failed to execute 'createObjectStore' on 'IDBDatabase': The a
utoIncrement option was set but the keyPath option was empty or an array. |
17 Expecting exception from store.createIndex('index-multientry', ['e', 'f'], {mult
iEntry: true}) | 17 Expecting exception from store.createIndex('index-multientry', ['e', 'f'], {mult
iEntry: true}) |
18 PASS Exception was thrown. | 18 PASS Exception was thrown. |
19 PASS code is DOMException.INVALID_ACCESS_ERR | 19 PASS code is DOMException.INVALID_ACCESS_ERR |
20 Exception message: The keyPath argument was an array and the multiEntry option i
s true. | 20 Exception message: Failed to execute 'createIndex' on 'IDBObjectStore': The keyP
ath argument was an array and the multiEntry option is true. |
21 | 21 |
22 Empty arrays are not valid key paths: | 22 Empty arrays are not valid key paths: |
23 Expecting exception from db.createObjectStore('store-keypath-empty-array', {keyP
ath: []}) | 23 Expecting exception from db.createObjectStore('store-keypath-empty-array', {keyP
ath: []}) |
24 PASS Exception was thrown. | 24 PASS Exception was thrown. |
25 PASS code is DOMException.SYNTAX_ERR | 25 PASS code is DOMException.SYNTAX_ERR |
26 Exception message: The keyPath option is not a valid key path. | 26 Exception message: Failed to execute 'createObjectStore' on 'IDBDatabase': The k
eyPath option is not a valid key path. |
27 Expecting exception from store.createIndex('index-keypath-empty-array', []) | 27 Expecting exception from store.createIndex('index-keypath-empty-array', []) |
28 PASS Exception was thrown. | 28 PASS Exception was thrown. |
29 PASS code is DOMException.SYNTAX_ERR | 29 PASS code is DOMException.SYNTAX_ERR |
30 Exception message: The keyPath argument contains an invalid key path. | 30 Exception message: Failed to execute 'createIndex' on 'IDBObjectStore': The keyP
ath argument contains an invalid key path. |
31 | 31 |
32 testKeyPaths(): | 32 testKeyPaths(): |
33 transaction = db.transaction(['store'], 'readwrite') | 33 transaction = db.transaction(['store'], 'readwrite') |
34 store = transaction.objectStore('store') | 34 store = transaction.objectStore('store') |
35 index = store.index('index') | 35 index = store.index('index') |
36 | 36 |
37 request = store.put({a: 1, b: 2, c: 3, d: 4}) | 37 request = store.put({a: 1, b: 2, c: 3, d: 4}) |
38 request = store.openCursor() | 38 request = store.openCursor() |
39 cursor = request.result | 39 cursor = request.result |
40 PASS cursor is non-null. | 40 PASS cursor is non-null. |
41 PASS JSON.stringify(cursor.key) is "[1,2]" | 41 PASS JSON.stringify(cursor.key) is "[1,2]" |
42 request = index.openCursor() | 42 request = index.openCursor() |
43 cursor = request.result | 43 cursor = request.result |
44 PASS cursor is non-null. | 44 PASS cursor is non-null. |
45 PASS JSON.stringify(cursor.primaryKey) is "[1,2]" | 45 PASS JSON.stringify(cursor.primaryKey) is "[1,2]" |
46 PASS JSON.stringify(cursor.key) is "[3,4]" | 46 PASS JSON.stringify(cursor.key) is "[3,4]" |
47 PASS successfullyParsed is true | 47 PASS successfullyParsed is true |
48 | 48 |
49 TEST COMPLETE | 49 TEST COMPLETE |
50 | 50 |
OLD | NEW |