1 <html> 2 <head> 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> 7 </head> 8 <body> 9 <p id="description"></p> 10 <div id="console"></div> 11 <script> 12 13 description("Test IndexedDB's transaction and objectStore calls"); 14 if (window.layoutTestController) 15 layoutTestController.waitUntilDone(); 16 17 function test() 18 { 19 shouldBeTrue("'webkitIndexedDB' in window"); 20 shouldBeFalse("webkitIndexedDB == null"); 21 22 request = evalAndLog("webkitIndexedDB.open('transaction-and-objectstore-calls', 'description')"); 23 request.onsuccess = openSuccess; 24 request.onerror = unexpectedErrorCallback; 25 } 26 27 function openSuccess() 28 { 29 window.db = evalAndLog("db = event.target.result"); 30 request = evalAndLog("result = db.setVersion('version 1')"); 31 request.onsuccess = cleanDatabase; 32 request.onerror = unexpectedErrorCallback; 33 } 34 35 function cleanDatabase() 36 { 37 trans = evalAndLog("trans = event.target.result"); 38 deleteAllObjectStores(db); 39 40 evalAndLog("db.createObjectStore('a')"); 41 evalAndLog("db.createObjectStore('b')"); 42 evalAndLog("trans.addEventListener('complete', created, true)"); 43 debug(""); 44 } 45 46 function created() 47 { 48 trans = evalAndLog("trans = db.transaction(['a'])"); 49 evalAndLog("trans.objectStore('a')"); 50 evalAndExpectException("trans.objectStore('b')", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 51 evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 52 debug(""); 53 54 trans = evalAndLog("trans = db.transaction(['a'])"); 55 evalAndLog("trans.objectStore('a')"); 56 evalAndExpectException("trans.objectStore('b')", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 57 evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 58 debug(""); 59 60 trans = evalAndLog("trans = db.transaction(['b'])"); 61 evalAndLog("trans.objectStore('b')"); 62 evalAndExpectException("trans.objectStore('a')", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 63 evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 64 debug(""); 65 66 trans = evalAndLog("trans = db.transaction(['a', 'b'])"); 67 evalAndLog("trans.objectStore('a')"); 68 evalAndLog("trans.objectStore('b')"); 69 evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 70 debug(""); 71 72 trans = evalAndLog("trans = db.transaction(['b', 'a'])"); 73 evalAndLog("trans.objectStore('a')"); 74 evalAndLog("trans.objectStore('b')"); 75 evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 76 debug(""); 77 78 trans = evalAndLog("trans = db.transaction([])"); 79 evalAndLog("trans.objectStore('a')"); 80 evalAndLog("trans.objectStore('b')"); 81 evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 82 debug(""); 83 84 trans = evalAndLog("trans = db.transaction()"); 85 evalAndLog("trans.objectStore('a')"); 86 evalAndLog("trans.objectStore('b')"); 87 evalAndExpectException("trans.objectStore('x')", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 88 debug(""); 89 90 evalAndExpectException("db.transaction(['x'])", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 91 evalAndExpectException("db.transaction(['x'])", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 92 evalAndExpectException("db.transaction(['a', 'x'])", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 93 evalAndExpectException("db.transaction(['x', 'x'])", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 94 evalAndExpectException("db.transaction(['a', 'x', 'b'])", "webkitIDBDatabaseException.NOT_FOUND_ERR"); 95 debug(""); 96 97 done(); 98 } 99 100 var successfullyParsed = true; 101 102 test(); 103 104 </script> 105 </body> 106 </html> 107