1 Test IndexedDB keyPath edge cases
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "keypath-edges.html"
7 indexedDB.deleteDatabase(dbname)
9 db.createObjectStore('store-with-path', {keyPath: 'foo'})
10 db.createObjectStore('store-with-path-and-generator', {keyPath: 'foo', autoIncrement: true})
13 transaction = db.transaction(['store-with-path'], 'readwrite')
14 store = transaction.objectStore('store-with-path')
16 Key path doesn't resolve to a value; should yield null, should throw DATA_ERR
17 Expecting exception from store.put(null)
18 PASS Exception was thrown.
20 PASS ename is 'DataError'
21 Exception message: Failed to execute 'put' on 'IDBObjectStore': Evaluating the object store's key path did not yield a value.
23 Key path doesn't resolve to a value; should yield null, should throw DATA_ERR
24 Expecting exception from store.put({})
25 PASS Exception was thrown.
27 PASS ename is 'DataError'
28 Exception message: Failed to execute 'put' on 'IDBObjectStore': Evaluating the object store's key path did not yield a value.
30 Key path resolves to a value that is invalid key; should yield 'invalid' key, should throw DATA_ERR
31 Expecting exception from store.put({foo: null})
32 PASS Exception was thrown.
34 PASS ename is 'DataError'
35 Exception message: Failed to execute 'put' on 'IDBObjectStore': Evaluating the object store's key path yielded a value that is not a valid key.
37 Key path resolves to a value that is valid key; should yield 'string' key, should succeed
38 store.put({foo: 'zoo'})
39 PASS store.put succeeded
41 testKeyPathsAndGenerator():
42 transaction = db.transaction(['store-with-path-and-generator'], 'readwrite')
43 store = transaction.objectStore('store-with-path-and-generator')
45 Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception
46 Expecting exception from store.put(null)
47 PASS Exception was thrown.
49 PASS ename is 'DataError'
50 Exception message: Failed to execute 'put' on 'IDBObjectStore': A generated key could not be inserted into the value.
52 Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception
53 Expecting exception from store.put('string')
54 PASS Exception was thrown.
56 PASS ename is 'DataError'
57 Exception message: Failed to execute 'put' on 'IDBObjectStore': A generated key could not be inserted into the value.
59 Key path doesn't resolve to a value; should yield null, key should be generated, put request should succeed
61 PASS store.put succeeded
63 Key path resolves to a value that is invalid key; should yield 'invalid' key, should throw DATA_ERR
64 Expecting exception from store.put({foo: null})
65 PASS Exception was thrown.
67 PASS ename is 'DataError'
68 Exception message: Failed to execute 'put' on 'IDBObjectStore': Evaluating the object store's key path yielded a value that is not a valid key.
70 Key path resolves to a value that is valid key; should yield 'string' key, should succeed
71 store.put({foo: 'zoo'})
72 PASS store.put succeeded
73 PASS successfullyParsed is true