JS Test Harness: Remove successfullyParsed from more tests
[WebKit-https.git] / LayoutTests / storage / indexeddb / mozilla / put-get-values.html
1 <!DOCTYPE html>
2 <!--
3   original test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_put_get_values.html
4   license of original test:
5     " Any copyright is dedicated to the Public Domain.
6       http://creativecommons.org/publicdomain/zero/1.0/ "
7 -->
8 <html>
9 <head>
10 <script src="../../../fast/js/resources/js-test-pre.js"></script>
11 <script src="../resources/shared.js"></script>
12 </head>
13 <body>
14 <p id="description"></p>
15 <div id="console"></div>
16 <script>
17
18 description("Test IndexedDB's putting and getting values in an object store");
19 if (window.layoutTestController)
20     layoutTestController.waitUntilDone();
21
22 function test()
23 {
24     indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
25     shouldBeFalse("indexedDB == 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     request = evalAndLog("request = db.setVersion('1')");
38     request.onsuccess = cleanDatabase;
39     request.onerror = unexpectedErrorCallback;
40 }
41
42 function cleanDatabase()
43 {
44     deleteAllObjectStores(db);
45
46     testString = evalAndLog("testString = { key: 0, value: 'testString' };");
47     testInt = evalAndLog("testInt = { key: 1, value: 1002 };");
48     objectStore = evalAndLog("objectStore = db.createObjectStore('Objects', { autoIncrement: false });");
49     request = evalAndLog("request = objectStore.add(testString.value, testString.key);");
50     request.onerror = unexpectedErrorCallback;
51     request.onsuccess = postAdd;
52 }
53
54 function postAdd()
55 {
56     shouldBe("event.target.result", "testString.key");
57     request = evalAndLog("request = objectStore.get(testString.key);");
58     request.onerror = unexpectedErrorCallback;
59     request.onsuccess = postGet;
60 }
61
62 function postGet()
63 {
64     shouldBe("event.target.result", "testString.value");
65     request = evalAndLog("request = objectStore.add(testInt.value, testInt.key);");
66     request.onerror = unexpectedErrorCallback;
67     request.onsuccess = postAddInt;
68 }
69
70 function postAddInt()
71 {
72     shouldBe("event.target.result", "testInt.key");
73     request = evalAndLog("request = objectStore.get(testInt.key);");
74     request.onerror = unexpectedErrorCallback;
75     request.onsuccess = postGetInt;
76 }
77
78 function postGetInt()
79 {
80     shouldBe("event.target.result", "testInt.value");
81     objectStoreAutoIncrement = evalAndLog("objectStoreAutoIncrement = db.createObjectStore('AutoIncremented Objects', { autoIncrement: true });");
82     request = evalAndLog("request = objectStoreAutoIncrement.add(testString.value);");
83     request.onerror = unexpectedErrorCallback;
84     request.onsuccess = postAddAutoIncrement;
85 }
86
87 function postAddAutoIncrement()
88 {
89     testString.key = evalAndLog("testString.key = event.target.result;");
90     request = evalAndLog("request = objectStoreAutoIncrement.get(testString.key);");
91     request.onerror = unexpectedErrorCallback;
92     request.onsuccess = postGetAutoIncrement;
93 }
94
95 function postGetAutoIncrement()
96 {
97     shouldBe("event.target.result", "testString.value");
98     request = evalAndLog("request = objectStoreAutoIncrement.add(testInt.value);");
99     request.onerror = unexpectedErrorCallback;
100     request.onsuccess = postAddIntAutoIncrement;
101 }
102
103 function postAddIntAutoIncrement()
104 {
105     testInt.key = evalAndLog("testInt.key = event.target.result;");
106     request = evalAndLog("request = objectStoreAutoIncrement.get(testInt.key);");
107     request.onerror = unexpectedErrorCallback;
108     request.onsuccess = postGetIntAutoIncrement;
109 }
110
111 function postGetIntAutoIncrement()
112 {
113     shouldBe("event.target.result", "testInt.value");
114     done();
115 }
116
117
118 test();
119
120 </script>
121 </body>
122 </html>
123