JS Test Harness: Remove successfullyParsed from more tests
[WebKit-https.git] / LayoutTests / storage / indexeddb / mozilla / key-requirements.html
1 <!DOCTYPE html>
2 <!--
3   original test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_key_requirements.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 event.target.result after add() and put()");
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
38     request = evalAndLog("request = db.setVersion('1')");
39     request.onsuccess = cleanDatabase;
40     request.onerror = unexpectedErrorCallback;
41 }
42
43 function cleanDatabase()
44 {
45     deleteAllObjectStores(db);
46     objectStore = evalAndLog("objectStore = db.createObjectStore('foo', { autoIncrement: true });");
47     request = evalAndLog("request = objectStore.add({});");
48     request.onsuccess = postAdd;
49     request.onerror = unexpectedErrorCallback;
50 }
51
52 function postAdd()
53 {
54     key1 = evalAndLog("key1 = event.target.result;");
55     request = evalAndLog("request = objectStore.put({}, key1);");
56     request.onsuccess = postPut1;
57     request.onerror = unexpectedErrorCallback;
58 }
59
60 function postPut1()
61 {
62     shouldBe("event.target.result", "key1");
63     key2 = evalAndLog("key2 = 10;");
64     request = evalAndLog("request = objectStore.put({}, key2);");
65     request.onsuccess = postPut2;
66     request.onerror = unexpectedErrorCallback;
67 }
68
69 function postPut2()
70 {
71     shouldBe("event.target.result", "key2");
72     key2 = evalAndLog("key2 = 100;");
73     request = evalAndLog("request = objectStore.put({}, key2);");
74     request.onsuccess = postPut3;
75     request.onerror = unexpectedErrorCallback;
76 }
77
78 function postPut3()
79 {
80     shouldBe("event.target.result", "key2");
81     done();
82 }
83
84
85 test();
86
87 </script>
88 </body>
89 </html>
90