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