| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>IndexedDB: Verify transaction activation behavior around microtasks</titl
e> | 2 <title>IndexedDB: Verify transaction activation behavior around microtasks</titl
e> |
| 3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 function idb_test(description, onUpgrade, onOpen) { | 7 function idb_test(description, onUpgrade, onOpen) { |
| 8 var t = async_test(description); | 8 var t = async_test(description); |
| 9 t.step(function() { | 9 t.step(function() { |
| 10 var dbName = 'db' + location.pathname + '-' + description; | 10 var dbName = 'db' + location.pathname + '-' + description; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 assert_false(isTransactionActive(tx, 'store'), | 51 assert_false(isTransactionActive(tx, 'store'), |
| 52 'Transaction should be inactive once control re
turns to event loop'); | 52 'Transaction should be inactive once control re
turns to event loop'); |
| 53 t.done(); | 53 t.done(); |
| 54 }), 0); | 54 }), 0); |
| 55 }); | 55 }); |
| 56 })); | 56 })); |
| 57 } | 57 } |
| 58 ); | 58 ); |
| 59 | 59 |
| 60 idb_test( | 60 idb_test( |
| 61 'Transactions created in microtasks resolved by host behavior are deactivate
d when control returns to the event loop', |
| 62 function(t, db) { |
| 63 db.createObjectStore('store'); |
| 64 }, |
| 65 function(t, db) { |
| 66 var aesAlgorithmKeyGen = {name: "AES-CBC", length: 128}; |
| 67 crypto.subtle.generateKey(aesAlgorithmKeyGen, false, ["encrypt"]).then(t
.step_func(function() { |
| 68 var tx = db.transaction('store'); |
| 69 var request = tx.objectStore('store').get(0); |
| 70 request.onerror = t.unreached_func('request should not fail'); |
| 71 request.onsuccess = t.step_func(function() { |
| 72 assert_true(isTransactionActive(tx, 'store'), |
| 73 'Transaction should be active during event dispatch'
); |
| 74 setTimeout(t.step_func(function() { |
| 75 assert_false(isTransactionActive(tx, 'store'), |
| 76 'Transaction should be inactive once control re
turns to event loop'); |
| 77 t.done(); |
| 78 }), 0); |
| 79 }); |
| 80 })); |
| 81 } |
| 82 ); |
| 83 |
| 84 idb_test( |
| 61 'Transactions created in microtasks remain active in subsequent microtasks', | 85 'Transactions created in microtasks remain active in subsequent microtasks', |
| 62 function(t, db) { | 86 function(t, db) { |
| 63 db.createObjectStore('store'); | 87 db.createObjectStore('store'); |
| 64 }, | 88 }, |
| 65 function(t, db) { | 89 function(t, db) { |
| 66 var tx; | 90 var tx; |
| 67 Promise.resolve().then(function() { | 91 Promise.resolve().then(function() { |
| 68 tx = db.transaction('store'); | 92 tx = db.transaction('store'); |
| 69 assert_true(isTransactionActive(tx, 'store'), | 93 assert_true(isTransactionActive(tx, 'store'), |
| 70 'Transaction should be active when created'); | 94 'Transaction should be active when created'); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 99 assert_false(isTransactionActive(tx, 'store'), | 123 assert_false(isTransactionActive(tx, 'store'), |
| 100 'Transaction should be inactive once control ret
urns to the event loop'); | 124 'Transaction should be inactive once control ret
urns to the event loop'); |
| 101 t.done(); | 125 t.done(); |
| 102 }), 0); | 126 }), 0); |
| 103 })); | 127 })); |
| 104 }); | 128 }); |
| 105 } | 129 } |
| 106 ); | 130 ); |
| 107 | 131 |
| 108 </script> | 132 </script> |
| OLD | NEW |