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