Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>IndexedDB: IDBCursor advance() Exception Ordering</title> | |
| 3 <meta charset=utf-8> | |
| 4 <link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbcursor-advance"> | |
| 5 <script src="../../resources/testharness.js"></script> | |
|
pwnall
2016/10/14 07:57:04
I think it'd be nice to add author information, to
jsbell
2016/10/17 19:42:03
Not something we'd normally do for blink and not a
| |
| 6 <script src="../../resources/testharnessreport.js"></script> | |
| 7 <script src="resources/testharness-helpers.js"></script> | |
| 8 <script> | |
| 9 | |
| 10 indexeddb_test( | |
| 11 (t, db) => { | |
| 12 const store = db.createObjectStore('s'); | |
| 13 store.put('value', 'key'); | |
| 14 }, | |
| 15 (t, db) => { | |
| 16 const tx = db.transaction('s'); | |
| 17 const store = tx.objectStore('s'); | |
| 18 const finish = pin_transaction(store); | |
|
pwnall
2016/10/14 07:57:04
I don't understand the necessity of the pin_transa
jsbell
2016/10/17 19:42:03
You're right - it doesn't matter for this test. Wi
| |
| 19 | |
| 20 const r = store.openKeyCursor(); | |
| 21 r.onsuccess = t.step_func(() => { | |
| 22 r.onsuccess = null; | |
| 23 | |
| 24 const cursor = r.result; | |
| 25 | |
| 26 setTimeout(t.step_func(() => { | |
| 27 assert_throws(new TypeError, () => { cursor.advance(0); }, | |
| 28 '"zero" check (TypeError) should precede ' + | |
| 29 '"not active" check (TransactionInactiveError)'); | |
| 30 finish(); | |
| 31 t.done(); | |
| 32 }), 0); | |
| 33 }); | |
| 34 }, | |
| 35 'IDBCursor.advance exception order: TypeError vs. TransactionInactiveError' | |
| 36 ); | |
| 37 | |
| 38 indexeddb_test( | |
| 39 (t, db) => { | |
| 40 const store = db.createObjectStore('s'); | |
| 41 const finish = pin_transaction(store); | |
|
pwnall
2016/10/14 07:57:04
Same as above, except I commented out setTimeout t
jsbell
2016/10/17 19:42:03
Done.
| |
| 42 | |
| 43 const s = db.createObjectStore('s2'); | |
| 44 s.put('value', 'key'); | |
| 45 | |
| 46 const r = s.openKeyCursor(); | |
| 47 r.onsuccess = t.step_func(() => { | |
| 48 r.onsuccess = null; | |
| 49 | |
| 50 const cursor = r.result; | |
| 51 db.deleteObjectStore('s2'); | |
| 52 | |
| 53 setTimeout(t.step_func(() => { | |
| 54 assert_throws('TransactionInactiveError', () => { cursor.advance(1); }, | |
| 55 '"not active" check (TransactionInactiveError) ' + | |
| 56 'should precede "deleted" check (InvalidStateError)'); | |
| 57 finish(); | |
| 58 t.done(); | |
| 59 }), 0); | |
| 60 }); | |
| 61 }, | |
| 62 (t, db) => {}, | |
| 63 'IDBCursor.advance exception order: ' + | |
| 64 'TransactionInactiveError vs. InvalidStateError #1' | |
| 65 ); | |
| 66 | |
| 67 indexeddb_test( | |
| 68 (t, db) => { | |
| 69 const store = db.createObjectStore('s'); | |
| 70 store.put('value', 'key'); | |
| 71 }, | |
| 72 (t, db) => { | |
| 73 const tx = db.transaction('s'); | |
| 74 const store = tx.objectStore('s'); | |
| 75 const finish = pin_transaction(store); | |
|
pwnall
2016/10/14 07:57:04
Same as above.
jsbell
2016/10/17 19:42:03
Done.
| |
| 76 | |
| 77 const r = store.openKeyCursor(); | |
| 78 r.onsuccess = t.step_func(() => { | |
| 79 r.onsuccess = null; | |
| 80 | |
| 81 const cursor = r.result; | |
| 82 cursor.continue(); | |
|
pwnall
2016/10/14 07:57:04
Is there any value in using advance() instead of c
jsbell
2016/10/17 19:42:03
Sure, switched. (I was considering `continue()` to
| |
| 83 | |
| 84 setTimeout(t.step_func(() => { | |
| 85 assert_throws('TransactionInactiveError', () => { cursor.advance(1); }, | |
| 86 '"not active" check (TransactionInactiveError) ' + | |
| 87 'should precede "got value" check (InvalidStateError)'); | |
| 88 finish(); | |
| 89 t.done(); | |
| 90 }), 0); | |
| 91 }); | |
| 92 }, | |
| 93 'IDBCursor.advance exception order: ' + | |
| 94 'TransactionInactiveError vs. InvalidStateError #2' | |
| 95 ); | |
| 96 | |
| 97 </script> | |
| OLD | NEW |