1 description("Ensure cursor calls behave as expected after cursor has run to the end.");
9 function prepareDatabase()
12 request = evalAndLog("indexedDB.deleteDatabase(dbname)");
13 request.onerror = unexpectedErrorCallback;
14 request.onblocked = unexpectedBlockedCallback;
15 request.onsuccess = onDeleteSuccess;
18 function onDeleteSuccess(evt)
21 request = evalAndLog("indexedDB.open(dbname, 1)");
22 request.onerror = unexpectedErrorCallback;
23 request.onblocked = unexpectedBlockedCallback;
24 request.onupgradeneeded = onUpgradeNeeded;
25 request.onsuccess = onOpenSuccess;
28 function onUpgradeNeeded(evt)
31 evalAndLog("db = event.target.result");
32 evalAndLog("store = db.createObjectStore('store')");
33 evalAndLog("store.put(1, 1)");
34 evalAndLog("store.put(2, 2)");
37 function onOpenSuccess(evt)
40 evalAndLog("db = event.target.result");
41 evalAndLog("transaction = db.transaction('store', 'readwrite')");
42 evalAndLog("store = transaction.objectStore('store')");
43 evalAndLog("count = 0");
44 evalAndLog("cursorRequest = store.openCursor()");
45 cursorRequest.onerror = unexpectedErrorCallback;
46 cursorRequest.onsuccess = onCursorSuccess;
49 function onCursorSuccess(evt)
52 evalAndLog("cursor = event.target.result");
54 shouldBeNonNull("cursor");
55 evalAndLog("count++");
56 evalAndLog("savedCursor = cursor");
57 evalAndLog("cursor.continue()");
59 shouldBeNull("cursor");
60 shouldBeNonNull("savedCursor");
63 evalAndExpectException("savedCursor.update('value')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
64 evalAndExpectException("savedCursor.advance(1)", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
65 evalAndExpectException("savedCursor.continue()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
66 evalAndExpectException("savedCursor.continue('key')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
67 evalAndExpectException("savedCursor.delete()", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");