idbcursor-delete-exception-order.any.js (2338B)
1 // META: global=window,worker 2 // META: title=IndexedDB: IDBCursor delete() Exception Ordering 3 // META: script=resources/support.js 4 5 // Spec: https://w3c.github.io/IndexedDB/#dom-idbcursor-delete 6 7 'use strict'; 8 9 indexeddb_test( 10 (t, db) => { 11 const s = db.createObjectStore('s'); 12 s.put('value', 'key'); 13 }, 14 (t, db) => { 15 const s = db.transaction('s', 'readonly').objectStore('s'); 16 const r = s.openCursor(); 17 r.onsuccess = t.step_func(() => { 18 r.onsuccess = null; 19 const cursor = r.result; 20 setTimeout( 21 t.step_func(() => { 22 assert_throws_dom( 23 'TransactionInactiveError', () => cursor.delete(), 24 '"Transaction inactive" check (TransactionInactiveError)' + 25 'should precede "read only" check(ReadOnlyError)'); 26 t.done(); 27 }), 28 0); 29 }); 30 }, 31 'IDBCursor.delete exception order: TransactionInactiveError vs. ReadOnlyError'); 32 33 indexeddb_test( 34 (t, db) => { 35 const s = db.createObjectStore('s'); 36 s.put('value', 'key'); 37 }, 38 (t, db) => { 39 const s = db.transaction('s', 'readonly').objectStore('s'); 40 const r = s.openCursor(); 41 r.onsuccess = t.step_func(() => { 42 r.onsuccess = null; 43 const cursor = r.result; 44 cursor.continue(); 45 assert_throws_dom( 46 'ReadOnlyError', () => cursor.delete(), 47 '"Read only" check (ReadOnlyError) should precede ' + 48 '"got value flag" (InvalidStateError) check'); 49 t.done(); 50 }); 51 }, 52 'IDBCursor.delete exception order: ReadOnlyError vs. InvalidStateError #1'); 53 54 indexeddb_test( 55 (t, db) => { 56 const s = db.createObjectStore('s'); 57 s.put('value', 'key'); 58 }, 59 (t, db) => { 60 const s = db.transaction('s', 'readonly').objectStore('s'); 61 const r = s.openKeyCursor(); 62 r.onsuccess = t.step_func(() => { 63 r.onsuccess = null; 64 const cursor = r.result; 65 assert_throws_dom( 66 'ReadOnlyError', () => cursor.delete(), 67 '"Read only" check (ReadOnlyError) should precede ' + 68 '"key only flag" (InvalidStateError) check'); 69 t.done(); 70 }); 71 }, 72 'IDBCursor.delete exception order: ReadOnlyError vs. InvalidStateError #2');