idbobjectstore-clear-exception-order.any.js (1606B)
1 // META: global=window,worker 2 // META: title=IndexedDB: IDBObjectStore clear() Exception Ordering 3 // META: script=resources/support.js 4 5 // Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-clear 6 7 'use strict'; 8 9 indexeddb_test( 10 (t, db) => { 11 const store = db.createObjectStore('s'); 12 const store2 = db.createObjectStore('s2'); 13 14 db.deleteObjectStore('s2'); 15 16 setTimeout( 17 t.step_func(() => { 18 assert_throws_dom( 19 'InvalidStateError', 20 () => { 21 store2.clear(); 22 }, 23 '"has been deleted" check (InvalidStateError) should precede ' + 24 '"not active" check (TransactionInactiveError)'); 25 t.done(); 26 }), 27 0); 28 }, 29 (t, db) => {}, 30 'IDBObjectStore.clear exception order: ' + 31 'InvalidStateError vs. TransactionInactiveError'); 32 33 indexeddb_test( 34 (t, db) => { 35 const store = db.createObjectStore('s'); 36 }, 37 (t, db) => { 38 const tx = db.transaction('s', 'readonly'); 39 const store = tx.objectStore('s'); 40 41 setTimeout( 42 t.step_func(() => { 43 assert_throws_dom( 44 'TransactionInactiveError', 45 () => { 46 store.clear(); 47 }, 48 '"not active" check (TransactionInactiveError) should precede ' + 49 '"read only" check (ReadOnlyError)'); 50 t.done(); 51 }), 52 0); 53 }, 54 55 'IDBObjectStore.clear exception order: ' + 56 'TransactionInactiveError vs. ReadOnlyError');