1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB cursor iterates correctly over values added during iteration.");
8 indexedDBTest(prepareDatabase, openCursor);
9 function prepareDatabase()
11 db = event.target.result;
12 trans = evalAndLog("trans = event.target.transaction");
13 shouldBeNonNull("trans");
14 trans.onabort = unexpectedAbortCallback;
16 var objectStore = evalAndLog("objectStore = db.createObjectStore('test')");
17 evalAndLog("objectStore.add(1, 1)");
18 evalAndLog("objectStore.add(2, 2)");
19 evalAndLog("objectStore.add(3, 3)");
24 evalAndLog("trans = db.transaction(['test'], 'readwrite')");
25 trans.onabort = finishJSTest;
26 trans.oncomplete = finishJSTest;
27 request = evalAndLog("trans.objectStore('test').openCursor()");
28 request.onsuccess = cursorSuccess;
29 request.onerror = unexpectedErrorCallback;
33 function cursorSuccess()
35 if (event.target.result == null) {
36 shouldBe("counter", "6");
40 counter = counter + 1;
42 shouldBe("event.target.result.key", String(counter));
43 if (event.target.result.key == 1) {
44 evalAndLog("trans.objectStore('test').add(6, 6)");
46 if (event.target.result.key == 2) {
47 evalAndLog("trans.objectStore('test').add(5, 5)");
49 if (event.target.result.key == 3) {
50 evalAndLog("trans.objectStore('test').add(4, 4)");
53 evalAndLog("event.target.result.continue()");