1 if (this.importScripts) {
2 importScripts('../../../resources/js-test.js');
3 importScripts('shared.js');
6 description("Test IndexedDB odd value datatypes");
10 testData = [{ description: 'empty string', name: '' },
11 { description: 'null', name: '\u0000' },
12 { description: 'faihu', name: '\ud800\udf46' },
13 { description: 'unpaired surrogate', name: '\ud800' },
14 { description: 'fffe', name: '\ufffe' },
15 { description: 'ffff', name: '\uffff' },
16 { description: 'line separator', name: '\u2028' }
20 debug("Deleting all the databases...");
21 for (var i = 0; i < testData.length; i++)
23 request = indexedDB.deleteDatabase(testData[i].name);
24 request.onblocked = unexpectedBlockedCallback;
25 request.onerror = unexpectedErrorCallback;
26 request.onsuccess = function() {
27 if (++numDeleted == testData.length)
33 function openNextDatabase()
35 debug("opening a database named " + testData[nextToOpen].description);
36 request = evalAndLog("indexedDB.open(testData[nextToOpen].name, 1)");
37 request.onsuccess = unexpectedSuccessCallback;
38 request.onblocked = unexpectedBlockedCallback;
39 request.onupgradeneeded = addAKey;
44 db = event.target.result;
45 evalAndLog("objectStore = db.createObjectStore(testData[nextToOpen].name);");
46 evalAndLog("index = objectStore.createIndex(testData[nextToOpen].name, 'keyPath');");
47 evalAndLog("key = testData[nextToOpen].name");
48 evalAndLog("request = objectStore.add(key, key);");
49 request.onsuccess = closeDatabase;
50 request.onerror = unexpectedErrorCallback;
53 function closeDatabase()
55 evalAndLog("db.close()");
57 if (++nextToOpen < testData.length) {
65 function verifyNextDatabase()
67 debug("reopening a database named " + testData[nextToOpen].description);
68 request = evalAndLog("indexedDB.open(testData[nextToOpen].name, 2)");
69 request.onblocked = unexpectedBlockedCallback;
70 request.onerror = unexpectedErrorCallback;
71 request.onupgradeneeded = getAKey;
76 evalAndLog("trans = event.target.transaction");
77 evalAndLog("objectStore = trans.objectStore(testData[nextToOpen].name);");
78 evalAndLog("key = testData[nextToOpen].name");
79 evalAndLog("request = objectStore.openCursor();");
80 request.onerror = unexpectedErrorCallback;
81 request.onsuccess = openCursorSuccess;
84 function openCursorSuccess()
86 evalAndLog("cursor = event.target.result;");
87 shouldBe("cursor.key", "testData[nextToOpen].name");
88 shouldBe("cursor.value", "testData[nextToOpen].name");
89 if (++nextToOpen < testData.length) {