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> | |
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 | |
19 const r = store.openKeyCursor(); | |
20 r.onsuccess = t.step_func(() => { | |
21 r.onsuccess = null; | |
22 | |
23 const cursor = r.result; | |
24 | |
25 setTimeout(t.step_func(() => { | |
26 assert_throws(new TypeError, () => { cursor.advance(0); }, | |
27 '"zero" check (TypeError) should precede ' + | |
28 '"not active" check (TransactionInactiveError)'); | |
29 t.done(); | |
30 }), 0); | |
31 }); | |
32 }, | |
33 'IDBCursor.advance exception order: TypeError vs. TransactionInactiveError' | |
34 ); | |
35 | |
36 indexeddb_test( | |
37 (t, db) => { | |
38 const store = db.createObjectStore('s'); | |
39 | |
40 const s = db.createObjectStore('s2'); | |
41 s.put('value', 'key'); | |
42 | |
43 const r = s.openKeyCursor(); | |
44 r.onsuccess = t.step_func(() => { | |
45 r.onsuccess = null; | |
46 | |
47 const cursor = r.result; | |
48 db.deleteObjectStore('s2'); | |
49 | |
50 setTimeout(t.step_func(() => { | |
51 assert_throws('TransactionInactiveError', () => { cursor.advance(1); }, | |
52 '"not active" check (TransactionInactiveError) ' + | |
53 'should precede "deleted" check (InvalidStateError)'); | |
54 t.done(); | |
55 }), 0); | |
56 }); | |
57 }, | |
58 (t, db) => {}, | |
59 'IDBCursor.advance exception order: ' + | |
60 'TransactionInactiveError vs. InvalidStateError #1' | |
61 ); | |
62 | |
63 indexeddb_test( | |
64 (t, db) => { | |
65 const store = db.createObjectStore('s'); | |
66 store.put('value', 'key'); | |
67 }, | |
68 (t, db) => { | |
69 const tx = db.transaction('s'); | |
70 const store = tx.objectStore('s'); | |
71 | |
72 const r = store.openKeyCursor(); | |
73 r.onsuccess = t.step_func(() => { | |
74 r.onsuccess = null; | |
75 | |
76 const cursor = r.result; | |
77 cursor.advance(1); | |
78 | |
79 setTimeout(t.step_func(() => { | |
80 assert_throws('TransactionInactiveError', () => { cursor.advance(1); }, | |
81 '"not active" check (TransactionInactiveError) ' + | |
82 'should precede "got value" check (InvalidStateError)'); | |
83 t.done(); | |
84 }), 0); | |
85 }); | |
86 }, | |
87 'IDBCursor.advance exception order: ' + | |
88 'TransactionInactiveError vs. InvalidStateError #2' | |
89 ); | |
90 | |
91 </script> | |
OLD | NEW |