Sync web-platform-tests up to revision a5b95cb31914507088a4eda16f7674bbc6f3313f
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / IndexedDB / upgrade-transaction-deactivation-timing.html
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>Upgrade transaction deactivation timing</title>
4 <link rel="help" href="http://localhost:4201/#upgrade-transaction-steps">
5 <script src=/resources/testharness.js></script>
6 <script src=/resources/testharnessreport.js></script>
7 <script src=support.js></script>
8 <script>
9
10 indexeddb_test(
11   (t, db, tx) => {
12     db.createObjectStore('store');
13     assert_true(is_transaction_active(tx, 'store'),
14                 'Transaction should be active in upgradeneeded callback');
15   },
16   (t, db) => { t.done(); },
17   'Upgrade transactions are active in upgradeneeded callback');
18
19 indexeddb_test(
20   (t, db, tx) => {
21     db.createObjectStore('store');
22     assert_true(is_transaction_active(tx, 'store'),
23                 'Transaction should be active in upgradeneeded callback');
24
25     Promise.resolve().then(t.step_func(() => {
26       assert_true(is_transaction_active(tx, 'store'),
27                   'Transaction should be active in microtask checkpoint');
28     }));
29   },
30   (t, db) => { t.done(); },
31   'Upgrade transactions are active in upgradeneeded callback and microtasks');
32
33
34 indexeddb_test(
35   (t, db, tx) => {
36     db.createObjectStore('store');
37     const release_tx = keep_alive(tx, 'store');
38
39     setTimeout(t.step_func(() => {
40       assert_false(is_transaction_active(tx, 'store'),
41                    'Transaction should be inactive in next task');
42       release_tx();
43     }), 0);
44   },
45   (t, db) => { t.done(); },
46   'Upgrade transactions are deactivated before next task');
47
48 </script>