| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>IndexedDB: IDBObjectStore add()/put() Exception Ordering</title> |
| 3 <meta charset=utf-8> |
| 4 <link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbobjectstore-add"> |
| 5 <link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbobjectstore-put"> |
| 6 <script src="../../resources/testharness.js"></script> |
| 7 <script src="../../resources/testharnessreport.js"></script> |
| 8 <script src="resources/testharness-helpers.js"></script> |
| 9 <script> |
| 10 |
| 11 ['add', 'put'].forEach(method => { |
| 12 indexeddb_test( |
| 13 (t, db) => { |
| 14 const store = db.createObjectStore('s'); |
| 15 const store2 = db.createObjectStore('s2'); |
| 16 |
| 17 db.deleteObjectStore('s2'); |
| 18 |
| 19 setTimeout(t.step_func(() => { |
| 20 assert_throws( |
| 21 'InvalidStateError', () => { store2[method]('key', 'value'); }, |
| 22 '"has been deleted" check (InvalidStateError) should precede ' + |
| 23 '"not active" check (TransactionInactiveError)'); |
| 24 t.done(); |
| 25 }), 0); |
| 26 }, |
| 27 (t, db) => {}, |
| 28 `IDBObjectStore.${method} exception order: ` + |
| 29 'InvalidStateError vs. TransactionInactiveError' |
| 30 ); |
| 31 |
| 32 indexeddb_test( |
| 33 (t, db) => { |
| 34 const store = db.createObjectStore('s'); |
| 35 }, |
| 36 (t, db) => { |
| 37 const tx = db.transaction('s', 'readonly'); |
| 38 const store = tx.objectStore('s'); |
| 39 |
| 40 setTimeout(t.step_func(() => { |
| 41 assert_throws( |
| 42 'TransactionInactiveError', () => { store[method]('key', 'value'); }, |
| 43 '"not active" check (TransactionInactiveError) should precede ' + |
| 44 '"read only" check (ReadOnlyError)'); |
| 45 t.done(); |
| 46 }), 0); |
| 47 }, |
| 48 |
| 49 `IDBObjectStore.${method} exception order: ` + |
| 50 'TransactionInactiveError vs. ReadOnlyError' |
| 51 ); |
| 52 |
| 53 indexeddb_test( |
| 54 (t, db) => { |
| 55 const store = db.createObjectStore('s'); |
| 56 }, |
| 57 (t, db) => { |
| 58 const tx = db.transaction('s', 'readonly'); |
| 59 const store = tx.objectStore('s'); |
| 60 |
| 61 assert_throws( |
| 62 'ReadOnlyError', () => { store[method]({}, 'value'); }, |
| 63 '"read only" check (ReadOnlyError) should precede ' + |
| 64 'key/data check (DataError)'); |
| 65 |
| 66 t.done(); |
| 67 }, |
| 68 |
| 69 `IDBObjectStore.${method} exception order: ` + |
| 70 'ReadOnlyError vs. DataError' |
| 71 ); |
| 72 }); |
| 73 |
| 74 </script> |
| OLD | NEW |