JS Test Harness: Remove successfullyParsed from more tests
[WebKit-https.git] / LayoutTests / storage / indexeddb / transaction-event-propagation.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 event propogation on IDBTransaction.");
12 if (window.layoutTestController) 
13     layoutTestController.waitUntilDone();
14
15 function test()
16 {
17     request = evalAndLog("webkitIndexedDB.open('transaction-event-propagation')");
18     request.onsuccess = setVersion;
19     request.onerror = unexpectedErrorCallback;
20 }
21
22 function setVersion()
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     trans.onabort = unexpectedAbortCallback;
36     evalAndLog("trans.oncomplete = startTest");
37
38     deleteAllObjectStores(db);
39
40     store = evalAndLog("store = db.createObjectStore('storeName', null)");
41     request = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
42     request.onerror = unexpectedErrorCallback;
43 }
44
45 function startTest()
46 {
47     debug("Verifing abort");
48     trans = evalAndLog("trans = db.transaction(['storeName'], webkitIDBTransaction.READ_WRITE)");
49     evalAndLog("trans.onabort = abortFiredCallback");
50     evalAndLog("trans.oncomplete = unexpectedAbortCallback");
51     evalAndLog("db.addEventListener('abort', dbAbortCaptureCallback, true)");
52     evalAndLog("db.addEventListener('abort', dbAbortBubbleCallback, false)");
53     evalAndLog("db.addEventListener('complete', unexpectedCompleteCallback, true)");
54     evalAndLog("db.addEventListener('complete', unexpectedCompleteCallback, false)");
55     store = evalAndLog("store = trans.objectStore('storeName')");
56     evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
57     dbCaptureFired = false;
58     abortFired = false;
59     dbBubbleFired1 = false;
60 }
61
62 function dbAbortCaptureCallback()
63 {
64     debug("");
65     debug("In IDBDatabase abort capture");
66     shouldBeFalse("dbCaptureFired");
67     shouldBeFalse("abortFired");
68     shouldBeFalse("dbBubbleFired1");
69     shouldBe("event.target", "trans");
70     shouldBe("event.currentTarget", "db");
71     dbCaptureFired = true;
72 }
73
74 function abortFiredCallback()
75 {
76     debug("");
77     debug("In abort handler");
78     shouldBeTrue("dbCaptureFired");
79     shouldBeFalse("abortFired");
80     shouldBeFalse("dbBubbleFired1");
81     shouldBe("event.target", "trans");
82     shouldBe("event.currentTarget", "trans");
83     abortFired = true;
84 }
85
86 function dbAbortBubbleCallback()
87 {
88     debug("");
89     debug("In IDBDatabase error bubble");
90     shouldBeTrue("dbCaptureFired");
91     shouldBeTrue("abortFired");
92     shouldBeFalse("dbBubbleFired1");
93     shouldBe("event.target", "trans");
94     shouldBe("event.currentTarget", "db");
95     dbBubbleFired1 = true;
96     debug("");
97     debug("Verifing success.");
98     trans = evalAndLog("trans = db.transaction(['storeName'], webkitIDBTransaction.READ_WRITE)");
99     evalAndLog("trans.oncomplete = completeFiredCallback");
100     evalAndLog("trans.onabort = unexpectedAbortCallback");
101     evalAndLog("db.removeEventListener('abort', dbAbortCaptureCallback, true)");
102     evalAndLog("db.removeEventListener('abort', dbAbortBubbleCallback, false)");
103     evalAndLog("db.removeEventListener('complete', unexpectedCompleteCallback, true)");
104     evalAndLog("db.removeEventListener('complete', unexpectedCompleteCallback, false)");
105     evalAndLog("db.addEventListener('complete', dbCompleteCaptureCallback, true)");
106     evalAndLog("db.addEventListener('complete', dbCompleteBubbleCallback, false)");
107     evalAndLog("db.addEventListener('abort', unexpectedAbortCallback, true)");
108     evalAndLog("db.addEventListener('abort', unexpectedAbortCallback, false)");
109     store = evalAndLog("store = trans.objectStore('storeName')");
110     evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key2')");
111     dbCaptureFired = false;
112     completeFired = false;
113     dbBubbleFired2 = false;
114 }
115
116 function dbCompleteCaptureCallback()
117 {
118     debug("");
119     debug("In IDBDatabase complete capture");
120     shouldBeFalse("dbCaptureFired");
121     shouldBeFalse("completeFired");
122     shouldBeFalse("dbBubbleFired2");
123     shouldBe("event.target", "trans");
124     shouldBe("event.currentTarget", "db");
125     dbCaptureFired = true;
126 }
127
128 function completeFiredCallback()
129 {
130     debug("");
131     debug("In IDBRequest handler");
132     shouldBeTrue("dbCaptureFired");
133     shouldBeFalse("completeFired");
134     shouldBeFalse("dbBubbleFired2");
135     shouldBe("event.target", "trans");
136     shouldBe("event.currentTarget", "trans");
137     completeFired = true;
138     debug("");
139     done();
140 }
141
142 function dbCompleteBubbleCallback()
143 {
144     debug("");
145     debug("In IDBDatabase complete bubble");
146     testFailed("Complete bubble callback should NOT fire");
147     dbBubbleFired2 = true;
148 }
149
150 test();
151
152
153 </script>
154 </body>
155 </html>