1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB's IDBObjectStore.delete(IDBKeyRange) method.");
8 indexedDBTest(prepareDatabase, runTests);
9 function prepareDatabase()
11 db = event.target.result;
12 evalAndLog("db.createObjectStore('store')");
15 function checkKeys(expected, callback)
17 debug("getting keys from store...");
18 debug("expect: " + JSON.stringify(expected));
20 request = store.openCursor();
21 request.onerror = unexpectedErrorCallback;
22 request.onsuccess = function () {
23 cursor = request.result;
25 keys.push(cursor.key);
28 debug("actual: " + JSON.stringify(keys));
29 if (JSON.stringify(expected) === JSON.stringify(keys)) {
32 testFailed("Don't match!");
39 { lower: 3, upper: 8, lowerOpen: false, upperOpen: false, expected: [1, 2, 9, 10]},
40 { lower: 3, upper: 8, lowerOpen: true, upperOpen: false, expected: [1, 2, 3, 9, 10]},
41 { lower: 3, upper: 8, lowerOpen: false, upperOpen: true, expected: [1, 2, 8, 9, 10]},
42 { lower: 3, upper: 8, lowerOpen: true, upperOpen: true, expected: [1, 2, 3, 8, 9, 10]}
48 var test = tests.shift();
51 evalAndLog("trans = db.transaction('store', 'readwrite')");
52 evalAndLog("store = trans.objectStore('store')");
53 for (i = 1; i <= 10; ++i) {
54 evalAndLog("store.put(" + i + "," + i + ")");
56 evalAndLog("store.delete(IDBKeyRange.bound(" +
59 test.lowerOpen + ", " +
60 test.upperOpen + "))");
61 checkKeys(test.expected, nextTest);
62 trans.onabort = unexpectedAbortCallback;
63 trans.oncomplete = nextTest;