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.
6 function cursorSuccess()
8 debug("Cursor opened successfully.");
9 // FIXME: check that we can iterate the cursor.
10 shouldBe("event.target.result.direction", "'next'");
11 shouldBe("event.target.result.key", "'myKey' + count");
12 shouldBe("event.target.result.value.keyPath", "'myKey' + count");
13 shouldBe("event.target.result.value.value", "'myValue' + count");
22 debug("Opening cursor #" + count
);
23 keyRange
= IDBKeyRange
.lowerBound("myKey" + count
);
24 request
= objectStore
.openCursor(keyRange
);
25 request
.onsuccess
= cursorSuccess
;
26 request
.onerror
= unexpectedErrorCallback
;
29 function populateObjectStore()
31 debug("Populating object store #" + count
);
32 obj
= {'keyPath': 'myKey' + count
, 'value': 'myValue' + count
};
33 request
= objectStore
.add(obj
);
34 request
.onerror
= unexpectedErrorCallback
;
37 request
.onsuccess
= openCursor
;
39 request
.onsuccess
= populateObjectStore
;
43 function createObjectStore()
45 debug('createObjectStore');
46 db
= event
.target
.result
;
47 window
.objectStore
= db
.createObjectStore('test', {keyPath
: 'keyPath'});
49 populateObjectStore();
54 indexedDBTest(createObjectStore
);