Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <meta charset=utf-8> | |
| 3 <title>Fire upgradeneeded 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}); | |
|
pwnall
2017/03/04 00:27:33
Cool, I didn't know about this. I may need to add
| |
| 9 | |
| 10 async_test(t => { | |
| 11 const dbname = document.location + '-' + t.name; | |
| 12 const del = indexedDB.deleteDatabase(dbname); | |
| 13 del.onerror = t.unreached_func('deleteDatabase should succeed'); | |
| 14 const open = indexedDB.open(dbname, 1); | |
| 15 let tx; | |
| 16 open.onupgradeneeded = () => { | |
| 17 tx = open.transaction; | |
| 18 throw Error(); | |
| 19 }; | |
| 20 open.onsuccess = t.unreached_func('open should fail'); | |
| 21 open.onerror = t.step_func_done(() => { | |
| 22 assert_equals(tx.error.name, 'AbortError'); | |
| 23 }); | |
| 24 }, 'Exception in upgradeneeded handler'); | |
| 25 | |
| 26 async_test(t => { | |
| 27 const dbname = document.location + '-' + t.name; | |
| 28 const del = indexedDB.deleteDatabase(dbname); | |
| 29 del.onerror = t.unreached_func('deleteDatabase should succeed'); | |
| 30 const open = indexedDB.open(dbname, 1); | |
| 31 let tx; | |
| 32 open.addEventListener('upgradeneeded', () => { | |
| 33 tx = open.transaction; | |
| 34 throw Error(); | |
| 35 }); | |
| 36 open.onsuccess = t.unreached_func('open should fail'); | |
| 37 open.onerror = t.step_func_done(() => { | |
| 38 assert_equals(tx.error.name, 'AbortError'); | |
| 39 }); | |
| 40 }, 'Exception in upgradeneeded listener'); | |
| 41 | |
| 42 async_test(t => { | |
| 43 const dbname = document.location + '-' + t.name; | |
| 44 const del = indexedDB.deleteDatabase(dbname); | |
| 45 del.onerror = t.unreached_func('deleteDatabase should succeed'); | |
| 46 const open = indexedDB.open(dbname, 1); | |
| 47 let tx; | |
| 48 open.addEventListener('upgradeneeded', () => { | |
| 49 // No-op. | |
| 50 }); | |
| 51 open.addEventListener('upgradeneeded', () => { | |
| 52 tx = open.transaction; | |
| 53 throw Error(); | |
| 54 }); | |
| 55 open.onsuccess = t.unreached_func('open should fail'); | |
| 56 open.onerror = t.step_func_done(() => { | |
| 57 assert_equals(tx.error.name, 'AbortError'); | |
| 58 }); | |
| 59 }, 'Exception in second upgradeneeded listener'); | |
| 60 | |
| 61 async_test(t => { | |
| 62 const dbname = document.location + '-' + t.name; | |
| 63 const del = indexedDB.deleteDatabase(dbname); | |
| 64 del.onerror = t.unreached_func('deleteDatabase should succeed'); | |
| 65 const open = indexedDB.open(dbname, 1); | |
| 66 let store; | |
|
pwnall
2017/03/04 00:27:33
I don't think you use store outside the block in 7
jsbell
2017/03/06 18:25:02
Thanks, left over from some refactoring. Removed.
| |
| 67 let tx; | |
| 68 let second_listener_called = false; | |
| 69 open.addEventListener('upgradeneeded', () => { | |
| 70 store = open.result.createObjectStore('s'); | |
| 71 throw Error(); | |
| 72 }); | |
| 73 open.addEventListener('upgradeneeded', t.step_func(() => { | |
| 74 second_listener_called = true; | |
| 75 tx = open.transaction; | |
| 76 assert_true(is_transaction_active(tx, 's'), | |
| 77 'Transaction should be active until dispatch completes'); | |
| 78 })); | |
| 79 open.onsuccess = t.unreached_func('open should fail'); | |
| 80 open.onerror = t.step_func_done(() => { | |
| 81 assert_true(second_listener_called); | |
| 82 assert_equals(tx.error.name, 'AbortError'); | |
| 83 }); | |
| 84 }, 'Exception in first upgradeneeded listener, tx active in second'); | |
| 85 | |
| 86 </script> | |
| OLD | NEW |