OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Fire success event - Exception thrown</title> |
| 4 <script src=/resources/testharness.js></script> |
| 5 <script src=/resources/testharnessreport.js></script> |
| 6 <script src=support.js></script> |
| 7 <script> |
| 8 setup({allow_uncaught_exception:true}); |
| 9 |
| 10 indexeddb_test( |
| 11 (t, db) => { |
| 12 db.createObjectStore('s'); |
| 13 }, |
| 14 (t, db) => { |
| 15 const tx = db.transaction('s'); |
| 16 const store = tx.objectStore('s'); |
| 17 const request = store.get(0); |
| 18 request.onsuccess = () => { |
| 19 throw Error(); |
| 20 }; |
| 21 tx.oncomplete = t.unreached_func('transaction should abort'); |
| 22 tx.onabort = t.step_func_done(() => { |
| 23 assert_equals(tx.error.name, 'AbortError'); |
| 24 }); |
| 25 }, |
| 26 'Exception in success event handler on request'); |
| 27 |
| 28 indexeddb_test( |
| 29 (t, db) => { |
| 30 db.createObjectStore('s'); |
| 31 }, |
| 32 (t, db) => { |
| 33 const tx = db.transaction('s'); |
| 34 const store = tx.objectStore('s'); |
| 35 const request = store.get(0); |
| 36 request.addEventListener('success', () => { |
| 37 throw Error(); |
| 38 }); |
| 39 tx.oncomplete = t.unreached_func('transaction should abort'); |
| 40 tx.onabort = t.step_func_done(() => { |
| 41 assert_equals(tx.error.name, 'AbortError'); |
| 42 }); |
| 43 }, |
| 44 'Exception in success event listener on request'); |
| 45 |
| 46 indexeddb_test( |
| 47 (t, db) => { |
| 48 db.createObjectStore('s'); |
| 49 }, |
| 50 (t, db) => { |
| 51 const tx = db.transaction('s'); |
| 52 const store = tx.objectStore('s'); |
| 53 const request = store.get(0); |
| 54 request.addEventListener('success', () => { |
| 55 // no-op |
| 56 }); |
| 57 request.addEventListener('success', () => { |
| 58 throw Error(); |
| 59 }); |
| 60 tx.oncomplete = t.unreached_func('transaction should abort'); |
| 61 tx.onabort = t.step_func_done(() => { |
| 62 assert_equals(tx.error.name, 'AbortError'); |
| 63 }); |
| 64 }, |
| 65 'Exception in second success event listener on request'); |
| 66 |
| 67 indexeddb_test( |
| 68 (t, db) => { |
| 69 db.createObjectStore('s'); |
| 70 }, |
| 71 (t, db) => { |
| 72 const tx = db.transaction('s'); |
| 73 const store = tx.objectStore('s'); |
| 74 const request = store.get(0); |
| 75 let second_listener_called = false; |
| 76 request.addEventListener('success', () => { |
| 77 throw Error(); |
| 78 }); |
| 79 request.addEventListener('success', t.step_func(() => { |
| 80 second_listener_called = true; |
| 81 assert_true(is_transaction_active(tx, 's'), |
| 82 'Transaction should be active until dispatch completes'); |
| 83 })); |
| 84 tx.oncomplete = t.unreached_func('transaction should abort'); |
| 85 tx.onabort = t.step_func_done(() => { |
| 86 assert_true(second_listener_called); |
| 87 assert_equals(tx.error.name, 'AbortError'); |
| 88 }); |
| 89 }, |
| 90 'Exception in first success event listener, tx active in second'); |
| 91 |
| 92 </script> |
OLD | NEW |