1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test consistency of IndexedDB's cursor objects.");
8 indexedDBTest(prepareDatabase, openBasicCursor);
9 function prepareDatabase()
11 db = event.target.result;
12 debug("setVersionSuccess():");
13 self.trans = evalAndLog("trans = event.target.transaction");
14 shouldBeNonNull("trans");
15 trans.onabort = unexpectedAbortCallback;
17 var objectStore = evalAndLog("objectStore = db.createObjectStore('basicStore')");
18 evalAndLog("objectStore.add('someValue1', 'someKey1').onerror = unexpectedErrorCallback");
19 evalAndLog("objectStore.add('someValue2', 'someKey2').onerror = unexpectedErrorCallback");
20 evalAndLog("objectStore.add('someValue3', 'someKey3').onerror = unexpectedErrorCallback");
21 evalAndLog("objectStore.add('someValue4', 'someKey4').onerror = unexpectedErrorCallback");
24 function openBasicCursor()
26 debug("openBasicCursor()");
27 evalAndLog("trans = db.transaction(['basicStore'], 'readwrite')");
28 trans.onabort = unexpectedAbortCallback;
29 trans.oncomplete = transactionComplete;
31 keyRange = IDBKeyRange.lowerBound("someKey1");
32 self.objectStore = evalAndLog("trans.objectStore('basicStore')");
33 request = evalAndLog("objectStore.openCursor(keyRange)");
34 request.onsuccess = checkCursor;
35 request.onerror = unexpectedErrorCallback;
40 function checkCursor()
43 debug("checkCursor()");
44 if (event.target.result == null) {
45 shouldBe("counter", "5");
48 if (storedCursor == null)
49 storedCursor = evalAndLog("storedCursor = event.target.result");
51 shouldBe("storedCursor", "event.target.result");
52 shouldBeEqualToString("storedCursor.key", "someKey" + counter);
53 shouldBeEqualToString("event.target.result.key", "someKey" + counter);
54 shouldBeEqualToString("storedCursor.value", "someValue" + counter);
55 shouldBeEqualToString("event.target.result.value", "someValue" + counter);
57 evalAndLog("event.target.result.continue()");
60 function transactionComplete()
62 debug("transactionComplete()");