Test IndexedDB cursor behavior On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". dbname = "cursors.html" indexedDB.deleteDatabase(dbname) indexedDB.open(dbname) db.createObjectStore('autoIncrement', { autoIncrement: true }); request = objectStore.openCursor(); PASS event.target.result is null db.createObjectStore('autoIncrementKeyPath', { keyPath: 'foo', autoIncrement: true }); request = objectStore.openCursor(); PASS event.target.result is null db.createObjectStore('keyPath', { keyPath: 'foo' }); request = objectStore.openCursor(); PASS event.target.result is null db.createObjectStore('foo'); request = objectStore.openCursor(); PASS event.target.result is null keys = [1, -1, 0, 10, 2000, 'q', 'z', 'two', 'b', 'a']; sortedKeys = [-1, 0, 1, 10, 2000, 'a', 'b', 'q', 'two', 'z']; keyIndex = 0; request = objectStore.add('foo', keys[i]); request = objectStore.add('foo', keys[i]); request = objectStore.add('foo', keys[i]); request = objectStore.add('foo', keys[i]); request = objectStore.add('foo', keys[i]); request = objectStore.add('foo', keys[i]); request = objectStore.add('foo', keys[i]); request = objectStore.add('foo', keys[i]); request = objectStore.add('foo', keys[i]); request = objectStore.add('foo', keys[i]); request = objectStore.openCursor(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); Expecting exception from cursor.continue(); PASS Exception was thrown. PASS code is DOMException.INVALID_STATE_ERR Exception message: Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end. PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); Expecting exception from cursor.continue(); PASS Exception was thrown. PASS code is DOMException.INVALID_STATE_ERR Exception message: Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end. PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); Expecting exception from cursor.continue(); PASS Exception was thrown. PASS code is DOMException.INVALID_STATE_ERR Exception message: Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end. PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); Expecting exception from cursor.continue(); PASS Exception was thrown. PASS code is DOMException.INVALID_STATE_ERR Exception message: Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end. PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); Expecting exception from cursor.continue(); PASS Exception was thrown. PASS code is DOMException.INVALID_STATE_ERR Exception message: Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end. PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); Expecting exception from cursor.continue(); PASS Exception was thrown. PASS code is DOMException.INVALID_STATE_ERR Exception message: Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end. PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); Expecting exception from cursor.continue(); PASS Exception was thrown. PASS code is DOMException.INVALID_STATE_ERR Exception message: Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end. PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); Expecting exception from cursor.continue(); PASS Exception was thrown. PASS code is DOMException.INVALID_STATE_ERR Exception message: Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end. PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); Expecting exception from cursor.continue(); PASS Exception was thrown. PASS code is DOMException.INVALID_STATE_ERR Exception message: Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end. PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); Expecting exception from cursor.continue(); PASS Exception was thrown. PASS code is DOMException.INVALID_STATE_ERR Exception message: Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end. PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS keyIndex is keys.length keyIndex = 4; range = IDBKeyRange.bound(2000, 'q'); request = objectStore.openCursor(range); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor = event.target.result; PASS keyIndex is 8 request = objectStore.openCursor(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue('b'); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 6; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 6; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 6; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 6; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 6; cursor = event.target.result; PASS keyIndex is keys.length keyIndex = 0; request = objectStore.openCursor(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(10); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 3; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 3; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 3; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 3; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 3; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 3; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 3; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1: 3; cursor = event.target.result; PASS keyIndex is keys.length keyIndex = 0; request = objectStore.openCursor(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue('c'); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1 : 7; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1 : 7; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1 : 7; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex += keyIndex ? 1 : 7; cursor = event.target.result; PASS keyIndex is keys.length keyIndex = 0; request = objectStore.openCursor(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' request = cursor.update('bar'); keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS keyIndex is keys.length request = objectStore.get(sortedKeys[4]); PASS event.target.result is 'bar' request = objectStore.put('foo', sortedKeys[4]); keyIndex = 0; request = objectStore.openCursor(null, 'next'); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' request = cursor.delete(); keyIndex++; cursor.continue(); PASS keyIndex is 5 gotRemoveEvent = true; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex++; cursor.continue(); cursor = event.target.result; PASS keyIndex is keys.length PASS gotRemoveEvent is true request = objectStore.get(sortedKeys[4]); PASS event.target.result is undefined request = objectStore.add('foo', sortedKeys[4]); request = objectStore.openCursor(null, 'prev'); cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex--; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex--; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex--; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex--; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex--; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex--; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex--; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex--; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex--; cursor = event.target.result; PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' cursor.continue(); PASS cursor.key is sortedKeys[keyIndex] PASS cursor.primaryKey is sortedKeys[keyIndex] PASS cursor.value is 'foo' keyIndex--; cursor = event.target.result; PASS keyIndex is -1 PASS successfullyParsed is true TEST COMPLETE