tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / storage / indexeddb / objectStore-required-arguments.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../fast/js/resources/js-test-pre.js"></script>
5 <script src="resources/shared.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10 <script>
11
12 description("Test IndexedDB object store required arguments");
13 if (window.layoutTestController)
14     layoutTestController.waitUntilDone();
15
16 function test()
17 {
18     indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
19     shouldBeFalse("indexedDB == null");
20     IDBDatabaseException = evalAndLog("IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException;");
21     shouldBeFalse("IDBDatabaseException == null");
22     IDBCursor = evalAndLog("IDBCursor = window.IDBCursor || window.webkitIDBCursor;");
23     shouldBeFalse("IDBCursor == null");
24     IDBKeyRange = evalAndLog("IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;");
25     shouldBeFalse("IDBKeyRange == null");
26
27     name = window.location.pathname;
28     description = "My Test Database";
29     request = evalAndLog("indexedDB.open(name, description)");
30     request.onsuccess = openSuccess;
31     request.onerror = unexpectedErrorCallback;
32 }
33
34 function openSuccess()
35 {
36     db = evalAndLog("db = event.target.result");
37
38     request = evalAndLog("request = db.setVersion('1')");
39     request.onsuccess = createAndPopulateObjectStore;
40     request.onerror = unexpectedErrorCallback;
41 }
42
43 function createAndPopulateObjectStore()
44 {
45     deleteAllObjectStores(db);
46
47     objectStore = evalAndLog("objectStore = db.createObjectStore('foo');");
48     shouldThrow("objectStore.put();");
49     shouldThrow("objectStore.add();");
50     shouldThrow("objectStore.delete();");
51     shouldThrow("objectStore.get();");
52     shouldThrow("objectStore.createIndex();");
53     shouldThrow("objectStore.createIndex('foo');");
54     shouldThrow("objectStore.index();");
55     shouldThrow("objectStore.deleteIndex();");
56     done();
57 }
58
59
60 test();
61
62 </script>
63 </body>
64 </html>