idbindex_openCursor.any.js (1847B)
1 // META: global=window,worker 2 // META: title=IDBIndex.openCursor() 3 // META: script=resources/support.js 4 'use strict'; 5 6 7 async_test(t => { 8 const open_rq = createdb(t); 9 10 open_rq.onupgradeneeded = t.step_func(e => { 11 const db = e.target.result; 12 const store = db.createObjectStore('store', {keyPath: 'key'}); 13 const index = store.createIndex('index', 'indexedProperty'); 14 15 store.add({key: 1, indexedProperty: 'data'}); 16 store.deleteIndex('index'); 17 18 assert_throws_dom('InvalidStateError', () => { 19 index.openCursor(); 20 }); 21 t.done(); 22 }); 23 }, 'If the index is deleted, throw InvalidStateError'); 24 25 async_test(t => { 26 let db; 27 const open_rq = createdb(t); 28 29 open_rq.onupgradeneeded = t.step_func(e => { 30 db = e.target.result; 31 const store = db.createObjectStore('store', {keyPath: 'key'}); 32 store.createIndex('index', 'indexedProperty'); 33 store.add({key: 1, indexedProperty: 'data'}); 34 }); 35 36 open_rq.onsuccess = t.step_func(e => { 37 db = e.target.result; 38 const tx = db.transaction('store', 'readonly'); 39 const index = tx.objectStore('store').index('index'); 40 tx.abort(); 41 42 assert_throws_dom('TransactionInactiveError', () => { 43 index.openCursor(); 44 }); 45 t.done(); 46 }); 47 }, 'If the transaction has been aborted, throw TransactionInactiveError'); 48 49 async_test(t => { 50 const open_rq = createdb(t); 51 52 open_rq.onupgradeneeded = t.step_func(e => { 53 const db = e.target.result; 54 const store = db.createObjectStore('store', {keyPath: 'key'}); 55 const index = store.createIndex('index', 'indexedProperty'); 56 store.add({key: 1, indexedProperty: 'data'}); 57 58 e.target.transaction.abort(); 59 60 assert_throws_dom('InvalidStateError', () => { 61 index.openCursor(); 62 }); 63 t.done(); 64 }); 65 }, 'If the index is deleted by an aborted upgrade, throw InvalidStateError');