idbcursor_continue_invalid.any.js (1193B)
1 // META: title=IDBCursor.continue() 2 // META: global=window,worker 3 // META: script=resources/support.js 4 5 'use strict'; 6 7 async_test(t => { 8 let db; 9 10 let open_rq = createdb(t); 11 open_rq.onupgradeneeded = function(e) { 12 db = e.target.result; 13 let objStore = db.createObjectStore('test'); 14 15 objStore.createIndex('index', ''); 16 17 objStore.add('data', 1); 18 objStore.add('data2', 2); 19 }; 20 21 open_rq.onsuccess = function(e) { 22 let count = 0; 23 let cursor_rq = db.transaction('test', 'readonly') 24 .objectStore('test') 25 .index('index') 26 .openCursor(); 27 28 cursor_rq.onsuccess = t.step_func(function(e) { 29 if (!e.target.result) { 30 assert_equals(count, 2, 'count'); 31 t.done(); 32 return; 33 } 34 let cursor = e.target.result; 35 36 cursor.continue(undefined); 37 38 // Second try 39 assert_throws_dom('InvalidStateError', function() { 40 cursor.continue(); 41 }, 'second continue'); 42 43 assert_throws_dom('InvalidStateError', function() { 44 cursor.continue(3); 45 }, 'third continue'); 46 47 count++; 48 }); 49 }; 50 }, 'Attempt to call continue two times');