tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / storage / indexeddb / readonly-properties.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 description("Test IndexedDB readonly properties");
12 if (window.layoutTestController)
13     layoutTestController.waitUntilDone();
14
15 function setReadonlyProperty(property, value)
16 {
17     oldValue = eval(property);
18     debug("trying to set readonly property " + property);
19     evalAndLog(property + " = " + value);
20     newValue = eval(property);
21     if (oldValue == newValue) {
22         testPassed(property + " is still " + oldValue);
23     } else {
24         testFailed(property + " value was changed to " + newValue);
25     }
26 }
27
28 function test()
29 {
30     indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
31     shouldBeFalse("indexedDB == null");
32     IDBDatabaseException = evalAndLog("IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException;");
33     shouldBeFalse("IDBDatabaseException == null");
34     IDBCursor = evalAndLog("IDBCursor = window.IDBCursor || window.webkitIDBCursor;");
35     shouldBeFalse("IDBCursor == null");
36     IDBKeyRange = evalAndLog("IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;");
37     shouldBeFalse("IDBKeyRange == null");
38
39     name = "foo";
40     description = "My Test Database";
41     request = evalAndLog("indexedDB.open(name, description)");
42     request.onsuccess = openSuccess;
43     request.onerror = unexpectedErrorCallback;
44 }
45
46 function openSuccess()
47 {
48     db = evalAndLog("db = event.target.result");
49     request = evalAndLog("request = db.setVersion('1')");
50     request.onsuccess = createAndPopulateObjectStore;
51     request.onerror = unexpectedErrorCallback;
52 }
53
54 function createAndPopulateObjectStore()
55 {
56     transaction = evalAndLog("transaction = event.target.result;");
57     deleteAllObjectStores(db);
58     objectStore = evalAndLog("objectStore = db.createObjectStore('foo');");
59     setReadonlyProperty("objectStore.transaction", "this");
60     done();
61 }
62
63
64 test();
65
66 </script>
67 </body>
68 </html>