Home | History | Annotate | Download | only in indexeddb
      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 create and removeObjectStore");
     14 if (window.layoutTestController)
     15     layoutTestController.waitUntilDone();
     16 
     17 function test()
     18 {
     19     request = evalAndLog("webkitIndexedDB.open('create-and-remove-object-store')");
     20     request.onsuccess = openSuccess;
     21     request.onerror = unexpectedErrorCallback;
     22 }
     23 
     24 function openSuccess()
     25 {
     26     debug("openSuccess():");
     27     window.db = evalAndLog("db = event.target.result");
     28     testCreateAndRemove();
     29     request = evalAndLog("result = db.setVersion('version 1')");
     30     request.onsuccess = cleanDatabase;
     31     request.onerror = unexpectedErrorCallback;
     32     testCreateAndRemove();
     33 }
     34 
     35 function testCreateAndRemove()
     36 {
     37     debug("Trying create");
     38     evalAndExpectException('db.createObjectStore("some os")', "webkitIDBDatabaseException.NOT_ALLOWED_ERR");
     39     debug("Trying remove");
     40     evalAndExpectException('db.createObjectStore("some os")', "webkitIDBDatabaseException.NOT_ALLOWED_ERR");
     41 }
     42 
     43 function cleanDatabase()
     44 {
     45     deleteAllObjectStores(db);
     46 
     47     os = evalAndLog("db.createObjectStore('tmp')");
     48     evalAndExpectException("db.createObjectStore('tmp')", "webkitIDBDatabaseException.CONSTRAINT_ERR");
     49 
     50     trans = evalAndLog("trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
     51     request = evalAndLog("trans.objectStore('tmp').get(0)");
     52     request.onsuccess = tryOnceMore;
     53     request.onerror = unexpectedErrorCallback;
     54 }
     55 
     56 function tryOnceMore()
     57 {
     58     shouldBeUndefined("event.target.result");
     59 
     60     testCreateAndRemove();
     61 
     62     done();
     63 }
     64 
     65 var successfullyParsed = true;
     66 
     67 test();
     68 
     69 </script>
     70 </body>
     71 </html>
     72