1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB keyPaths");
8 testData = [{ name: "simple identifier",
12 { name: "simple identifiers",
13 value: {id1:10, id2:20},
16 { name: "nested identifiers",
17 value: {outer:{inner:10}},
18 keyPath: "outer.inner",
20 { name: "nested identifiers with distractions",
21 value: {outer:{inner:10}, inner:{outer:20}},
22 keyPath: "outer.inner",
27 indexedDBTest(prepareDatabase);
30 function prepareDatabase()
32 db = db || event.target.result;
34 trans = event.target.transaction;
35 trans.onabort = unexpectedAbortCallback;
38 debug("testing " + testData[nextToOpen].name);
39 deleteAllObjectStores(db);
40 objectStore = evalAndLog("objectStore = db.createObjectStore(testData[nextToOpen].name, {keyPath: testData[nextToOpen].keyPath});");
41 result = evalAndLog("result = objectStore.add(testData[nextToOpen].value);");
42 result.onerror = unexpectedErrorCallback;
43 result.onsuccess = openCursor;
48 result = evalAndLog("result = objectStore.openCursor();");
49 result.onerror = unexpectedErrorCallback;
50 result.onsuccess = checkCursor;
53 function checkCursor()
55 cursor = evalAndLog("cursor = event.target.result;");
57 shouldBe("cursor.key", "testData[nextToOpen].key");
59 testFailed("cursor is null");
61 if (++nextToOpen < testData.length) {