1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 function emptyCursorSuccess()
7 debug('Empty cursor opened successfully.')
11 function openEmptyCursor()
13 debug('Opening an empty cursor.');
14 keyRange = webkitIDBKeyRange.lowerBound('InexistentKey');
15 request = objectStore.openCursor(keyRange);
16 request.onsuccess = emptyCursorSuccess;
17 request.onerror = unexpectedErrorCallback;
20 function cursorSuccess()
22 var cursor = event.target.result;
23 if (cursor === null) {
24 debug('Cursor reached end of range.');
29 debug('Cursor opened successfully.');
30 shouldBe("event.target.result.direction", "'next'");
31 shouldBe("event.target.result.key", "3.14");
32 shouldBe("event.target.result.value", "'myValue'");
37 function openCursor(objectStore)
39 debug('Opening cursor');
40 var keyRange = webkitIDBKeyRange.lowerBound(3.12);
41 var request = objectStore.openCursor(keyRange);
42 request.onsuccess = cursorSuccess;
43 request.onerror = unexpectedErrorCallback;
46 function dataAddedSuccess()
49 openCursor(objectStore);
52 function populateObjectStore()
54 debug('Populating object store');
55 db = event.target.result;
56 deleteAllObjectStores(db);
57 window.objectStore = db.createObjectStore('test');
58 var request = objectStore.add('myValue', 3.14);
59 request.onsuccess = dataAddedSuccess;
60 request.onerror = unexpectedErrorCallback;
64 indexedDBTest(populateObjectStore);