| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <title>IndexedDB: IDBDatabase createObjectStore() Exception Ordering</title> | |
| 3 <meta charset=utf-8> | |
| 4 <link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbdatabase-createob
jectstore"> | |
| 5 <script src="../../resources/testharness.js"></script> | |
| 6 <script src="../../resources/testharnessreport.js"></script> | |
| 7 <script src="resources/testharness-helpers.js"></script> | |
| 8 <script> | |
| 9 | |
| 10 indexeddb_test( | |
| 11 (t, db, req) => { | |
| 12 db.createObjectStore('s'); | |
| 13 | |
| 14 req.transaction.onabort = () => { | |
| 15 setTimeout(t.step_func(() => { | |
| 16 assert_throws( | |
| 17 'InvalidStateError', () => { db.createObjectStore('s2'); }, | |
| 18 '"running an upgrade transaction" check (InvalidStateError) ' + | |
| 19 'should precede "not active" check (TransactionInactiveError)'); | |
| 20 | |
| 21 t.done(); | |
| 22 }), 0); | |
| 23 }; | |
| 24 req.onerror = null; | |
| 25 req.transaction.abort(); | |
| 26 }, | |
| 27 (t, db) => { t.assert_unreached('open should fail'); }, | |
| 28 'IDBDatabase.createObjectStore exception order: ' + | |
| 29 'InvalidStateError vs. TransactionInactiveError' | |
| 30 ); | |
| 31 | |
| 32 indexeddb_test( | |
| 33 (t, db, req) => { | |
| 34 const store = db.createObjectStore('s'); | |
| 35 | |
| 36 req.onerror = null; | |
| 37 req.transaction.abort(); | |
| 38 | |
| 39 assert_throws( | |
| 40 'TransactionInactiveError', | |
| 41 () => { db.createObjectStore('s2', {keyPath: '-invalid-'}); }, | |
| 42 '"not active" check (TransactionInactiveError) should precede ' + | |
| 43 '"valid key path" check (SyntaxError)'); | |
| 44 | |
| 45 t.done(); | |
| 46 }, | |
| 47 (t, db) => { t.assert_unreached('open should fail'); }, | |
| 48 'IDBDatabase.createObjectStore exception order: ' + | |
| 49 'TransactionInactiveError vs. SyntaxError' | |
| 50 ); | |
| 51 | |
| 52 indexeddb_test( | |
| 53 (t, db) => { | |
| 54 db.createObjectStore('s'); | |
| 55 assert_throws('SyntaxError', () => { | |
| 56 db.createObjectStore('s', {keyPath: 'not a valid key path'}); | |
| 57 }, '"Invalid key path" check (SyntaxError) should precede ' + | |
| 58 '"duplicate store name" check (ConstraintError)'); | |
| 59 t.done(); | |
| 60 }, | |
| 61 (t, db) => {}, | |
| 62 'IDBDatabase.createObjectStore exception order: ' + | |
| 63 'SyntaxError vs. ConstraintError' | |
| 64 ); | |
| 65 | |
| 66 indexeddb_test( | |
| 67 (t, db) => { | |
| 68 db.createObjectStore('s'); | |
| 69 assert_throws('ConstraintError', () => { | |
| 70 db.createObjectStore('s', {autoIncrement: true, | |
| 71 keyPath: ''}); | |
| 72 }, '"already exists" check (ConstraintError) should precede ' + | |
| 73 '"autoIncrement vs. keyPath" check (InvalidAccessError)'); | |
| 74 t.done(); | |
| 75 }, | |
| 76 (t, db) => {}, | |
| 77 'IDBDatabase.createObjectStore exception order: ' + | |
| 78 'ConstraintError vs. InvalidAccessError' | |
| 79 ); | |
| 80 | |
| 81 </script> | |
| OLD | NEW |