Add ICU message format support
[chromium-blink-merge.git] / content / test / data / indexeddb / cursor_test.js
blob98b10d0ba5c91906108356ede84288a358ebb0aa
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.');
8 done();
11 function openEmptyCursor()
13 debug('Opening an empty cursor.');
14 keyRange = IDBKeyRange.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.');
25 openEmptyCursor();
26 return;
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'");
34 cursor.continue();
37 function openCursor(objectStore)
39 debug('Opening cursor');
40 var keyRange = IDBKeyRange.lowerBound(3.12);
41 var request = objectStore.openCursor(keyRange);
42 request.onsuccess = cursorSuccess;
43 request.onerror = unexpectedErrorCallback;
46 function dataAddedSuccess()
48 debug('Data added');
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;
63 function test() {
64 indexedDBTest(populateObjectStore);