3 <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
4 <script src="../../fast/js/resources/js-test-pre.js"></script>
5 <script src="../../fast/js/resources/js-test-post-function.js"></script>
6 <script src="resources/shared.js"></script>
9 <p id="description"></p>
10 <div id="console"></div>
13 description("Test the basics of IndexedDB's IDBDatabase.");
14 if (window.layoutTestController)
15 layoutTestController.waitUntilDone();
17 function openSuccess()
19 verifySuccessEvent(event);
21 var db = evalAndLog("db = event.result");
22 deleteAllObjectStores(db);
24 // We must do something asynchronous before anything synchronous since
25 // deleteAllObjectStores only schedules the object stores to be removed.
26 // We don't know for sure whether it's happened until an IDBRequest object
27 // that was created after the removes fires.
29 debug("Testing setVersion.");
30 result = evalAndLog('db.setVersion("version a")');
32 result.onsuccess = setVersionAgain;
33 result.onError = unexpectedErrorCallback;
36 function setVersionAgain()
38 verifySuccessEvent(event);
40 result = evalAndLog('db.setVersion("version b")');
42 result.onsuccess = createObjectStore;
43 result.onError = unexpectedErrorCallback;
46 function createObjectStore()
48 verifySuccessEvent(event);
49 shouldBeEqualToString("db.version", "version b");
50 shouldBeEqualToString("db.name", "name");
51 shouldBe("db.objectStores", "[]");
52 shouldBe("db.objectStores.length", "0");
53 shouldBe("db.objectStores.contains('')", "false");
55 result = evalAndLog('db.createObjectStore("test123")');
57 result.onsuccess = checkObjectStore;
58 result.onError = unexpectedErrorCallback;
61 function checkObjectStore()
63 verifySuccessEvent(event);
64 shouldBe("db.objectStores", "['test123']");
65 shouldBe("db.objectStores.length", "1");
66 shouldBe("db.objectStores.contains('')", "false");
67 shouldBe("db.objectStores.contains('test456')", "false");
68 shouldBe("db.objectStores.contains('test123')", "true");
75 result = evalAndLog("indexedDB.open('name', 'description')");
77 result.onsuccess = openSuccess;
78 result.onerror = unexpectedErrorCallback;
83 var successfullyParsed = true;