JS Test Harness: Remove successfullyParsed from more tests
[WebKit-https.git] / LayoutTests / storage / indexeddb / objectstore-clear.html
1 <html>
2 <head>
3 <script src="../../fast/js/resources/js-test-pre.js"></script>
4 <script src="resources/shared.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10
11 description("Test IndexedDB's webkitIDBObjectStore.clear().");
12 if (window.layoutTestController)
13     layoutTestController.waitUntilDone();
14
15 function test()
16 {
17     request = evalAndLog("webkitIndexedDB.open('objectstore-clear')");
18     request.onsuccess = startSetVersion;
19     request.onerror = unexpectedErrorCallback;
20 }
21
22 function startSetVersion()
23 {
24     db = evalAndLog("db = event.target.result");
25
26     request = evalAndLog("db.setVersion('new version')");
27     request.onsuccess = deleteExisting;
28     request.onerror = unexpectedErrorCallback;
29 }
30
31 function deleteExisting()
32 {
33     window.trans = evalAndLog("trans = event.target.result");
34     shouldBeTrue("trans !== null");
35
36     deleteAllObjectStores(db);
37
38     store = evalAndLog("store = db.createObjectStore('storeName', null)");
39
40     window.index = evalAndLog("store.createIndex('indexName', '')");
41     shouldBeTrue("store.indexNames.contains('indexName')");
42
43     request = evalAndLog("store.add('value', 'key')");
44     request.onsuccess = createSecondObjectStoreAndAddValue;
45     request.onerror = unexpectedErrorCallback;
46 }
47
48 function createSecondObjectStoreAndAddValue()
49 {
50     otherStore = evalAndLog("otherStore = db.createObjectStore('otherStoreName', null)");
51
52     request = evalAndLog("otherStore.add('value', 'key')");
53     request.onsuccess = clearObjectStore;
54     request.onerror = unexpectedErrorCallback;
55 }
56
57 function clearObjectStore()
58 {
59     request = evalAndLog("store.clear()");
60     request.onsuccess = clearSuccess;
61     request.onerror = unexpectedErrorCallback;
62 }
63
64 function clearSuccess()
65 {
66     shouldBeUndefined("event.target.result");
67
68     request = evalAndLog("store.openCursor()");
69     request.onsuccess = openCursorSuccess;
70     request.onerror = unexpectedErrorCallback;
71 }
72
73 function openCursorSuccess()
74 {
75     shouldBeNull("event.target.result");
76
77     index = evalAndLog("index = store.index('indexName')");
78     request = evalAndLog("index.openKeyCursor()");
79     request.onsuccess = openKeyCursorSuccess;
80     request.onerror = unexpectedErrorCallback;
81 }
82
83 function openKeyCursorSuccess()
84 {
85     debug("openKeyCursorSuccess():");
86     shouldBeNull("event.target.result");
87
88     transaction = evalAndLog("db.transaction(['otherStoreName'])");
89     transaction.onabort = unexpectedErrorCallback;
90     var otherStore = evalAndLog("otherStore = transaction.objectStore('otherStoreName')");
91
92     request = evalAndLog("otherStore.get('key')");
93     request.onsuccess = getSuccess;
94     request.onerror = unexpectedErrorCallback;
95 }
96
97 function getSuccess()
98 {
99     shouldBeEqualToString("event.target.result", "value");
100
101     done();
102 }
103
104 test();
105
106 </script>
107 </body>
108 </html>