OLD | NEW |
1 Test IndexedDB keyPath edge cases | 1 Test IndexedDB keyPath edge cases |
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-edges.html" | 8 dbname = "keypath-edges.html" |
9 indexedDB.deleteDatabase(dbname) | 9 indexedDB.deleteDatabase(dbname) |
10 indexedDB.open(dbname) | 10 indexedDB.open(dbname) |
11 db.createObjectStore('store-with-path', {keyPath: 'foo'}) | 11 db.createObjectStore('store-with-path', {keyPath: 'foo'}) |
12 db.createObjectStore('store-with-path-and-generator', {keyPath: 'foo', autoIncre
ment: true}) | 12 db.createObjectStore('store-with-path-and-generator', {keyPath: 'foo', autoIncre
ment: true}) |
13 | 13 |
14 testKeyPaths(): | 14 testKeyPaths(): |
15 transaction = db.transaction(['store-with-path'], 'readwrite') | 15 transaction = db.transaction(['store-with-path'], 'readwrite') |
16 store = transaction.objectStore('store-with-path') | 16 store = transaction.objectStore('store-with-path') |
17 | 17 |
18 Key path doesn't resolve to a value; should yield null, should throw DATA_ERR | 18 Key path doesn't resolve to a value; should yield null, should throw DATA_ERR |
19 Expecting exception from store.put(null) | 19 Expecting exception from store.put(null) |
20 PASS Exception was thrown. | 20 PASS Exception was thrown. |
21 PASS code is 0 | 21 PASS code is 0 |
22 PASS ename is 'DataError' | 22 PASS ename is 'DataError' |
| 23 Exception message: Evaluating the object store's key path did not yield a value. |
23 | 24 |
24 Key path doesn't resolve to a value; should yield null, should throw DATA_ERR | 25 Key path doesn't resolve to a value; should yield null, should throw DATA_ERR |
25 Expecting exception from store.put({}) | 26 Expecting exception from store.put({}) |
26 PASS Exception was thrown. | 27 PASS Exception was thrown. |
27 PASS code is 0 | 28 PASS code is 0 |
28 PASS ename is 'DataError' | 29 PASS ename is 'DataError' |
| 30 Exception message: Evaluating the object store's key path did not yield a value. |
29 | 31 |
30 Key path resolves to a value that is invalid key; should yield 'invalid' key, sh
ould throw DATA_ERR | 32 Key path resolves to a value that is invalid key; should yield 'invalid' key, sh
ould throw DATA_ERR |
31 Expecting exception from store.put({foo: null}) | 33 Expecting exception from store.put({foo: null}) |
32 PASS Exception was thrown. | 34 PASS Exception was thrown. |
33 PASS code is 0 | 35 PASS code is 0 |
34 PASS ename is 'DataError' | 36 PASS ename is 'DataError' |
| 37 Exception message: Evaluating the object store's key path yielded a value that i
s not a valid key. |
35 | 38 |
36 Key path resolves to a value that is valid key; should yield 'string' key, shoul
d succeed | 39 Key path resolves to a value that is valid key; should yield 'string' key, shoul
d succeed |
37 store.put({foo: 'zoo'}) | 40 store.put({foo: 'zoo'}) |
38 PASS store.put succeeded | 41 PASS store.put succeeded |
39 | 42 |
40 testKeyPathsAndGenerator(): | 43 testKeyPathsAndGenerator(): |
41 transaction = db.transaction(['store-with-path-and-generator'], 'readwrite') | 44 transaction = db.transaction(['store-with-path-and-generator'], 'readwrite') |
42 store = transaction.objectStore('store-with-path-and-generator') | 45 store = transaction.objectStore('store-with-path-and-generator') |
43 | 46 |
44 Key path doesn't resolve to a value; should yield null but insertion would fail,
so put request should raise exception | 47 Key path doesn't resolve to a value; should yield null but insertion would fail,
so put request should raise exception |
45 Expecting exception from store.put(null) | 48 Expecting exception from store.put(null) |
46 PASS Exception was thrown. | 49 PASS Exception was thrown. |
47 PASS code is 0 | 50 PASS code is 0 |
48 PASS ename is 'DataError' | 51 PASS ename is 'DataError' |
| 52 Exception message: A generated key could not be inserted into the value. |
49 | 53 |
50 Key path doesn't resolve to a value; should yield null but insertion would fail,
so put request should raise exception | 54 Key path doesn't resolve to a value; should yield null but insertion would fail,
so put request should raise exception |
51 Expecting exception from store.put('string') | 55 Expecting exception from store.put('string') |
52 PASS Exception was thrown. | 56 PASS Exception was thrown. |
53 PASS code is 0 | 57 PASS code is 0 |
54 PASS ename is 'DataError' | 58 PASS ename is 'DataError' |
| 59 Exception message: A generated key could not be inserted into the value. |
55 | 60 |
56 Key path doesn't resolve to a value; should yield null, key should be generated,
put request should succeed | 61 Key path doesn't resolve to a value; should yield null, key should be generated,
put request should succeed |
57 store.put({}) | 62 store.put({}) |
58 PASS store.put succeeded | 63 PASS store.put succeeded |
59 | 64 |
60 Key path resolves to a value that is invalid key; should yield 'invalid' key, sh
ould throw DATA_ERR | 65 Key path resolves to a value that is invalid key; should yield 'invalid' key, sh
ould throw DATA_ERR |
61 Expecting exception from store.put({foo: null}) | 66 Expecting exception from store.put({foo: null}) |
62 PASS Exception was thrown. | 67 PASS Exception was thrown. |
63 PASS code is 0 | 68 PASS code is 0 |
64 PASS ename is 'DataError' | 69 PASS ename is 'DataError' |
| 70 Exception message: Evaluating the object store's key path yielded a value that i
s not a valid key. |
65 | 71 |
66 Key path resolves to a value that is valid key; should yield 'string' key, shoul
d succeed | 72 Key path resolves to a value that is valid key; should yield 'string' key, shoul
d succeed |
67 store.put({foo: 'zoo'}) | 73 store.put({foo: 'zoo'}) |
68 PASS store.put succeeded | 74 PASS store.put succeeded |
69 PASS successfullyParsed is true | 75 PASS successfullyParsed is true |
70 | 76 |
71 TEST COMPLETE | 77 TEST COMPLETE |
72 | 78 |
OLD | NEW |