Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / websql / transaction-error-callback.html
blobec2d4eb3074a3c761c30c1aba7949ac100425320
1 <html>
2 <head>
3 <script>
5 function log(message)
7 document.getElementById("console").innerHTML += message + "<br>";
10 // signal to testRunner when this reaches zero.
11 var testCount = 4;
12 // we first retrieve and store the number of rows already in our test database.
13 // our goal is to keep the number unchanged through the tests.
14 var initialRowCount = 0;
15 var database;
16 var successCallbackCalled;
18 function finishTest()
20 if (--testCount)
21 return;
23 log("All Tests are complete.");
25 if (window.testRunner)
26 testRunner.notifyDone();
29 function successCallback()
31 successCallbackCalled = true;
34 function verifySuccess(msg)
36 database.transaction(function(tx)
38 tx.executeSql("SELECT count(*) AS count FROM ErrorCallbackTest", [], function(tx, rs)
40 log(msg + " : " + (rs.rows.item(0).count == initialRowCount && !successCallbackCalled ? "SUCCESS" : "FAILURE"));
41 finishTest();
42 });
43 });
46 function failMidWay(errorCallback)
48 successCallbackCalled = false;
49 database.transaction(function(tx)
51 tx.executeSql("INSERT INTO ErrorCallbackTest(someValue) VALUES(?);", [ 1 ]);
52 tx.executeSql("MUTTER SOMETHING ILLEGIBLE");
53 }, errorCallback, successCallback);
56 function statementCallbackThrowsException(errorCallback)
58 successCallbackCalled = false;
59 database.transaction(function(tx)
61 tx.executeSql("INSERT INTO ErrorCallbackTest(someValue) VALUES(?);", [ 1 ], function()
63 throw {};
64 });
65 });
68 function runTest()
70 if (window.testRunner) {
71 testRunner.clearAllDatabases();
72 testRunner.dumpAsText();
73 testRunner.waitUntilDone();
76 database = openDatabase("ErrorCallbackDatabase", "1.0", "Test for error callback", 1);
77 database.transaction(function(tx)
79 tx.executeSql("CREATE TABLE IF NOT EXISTS ErrorCallbackTest (someValue)", []);
80 tx.executeSql("SELECT count(*) AS count FROM ErrorCallbackTest", [], function(tx, rs)
82 initialRowCount = rs.rows.item(0).count;
83 });
84 });
86 failMidWay(function() { return true; });
87 verifySuccess("Testing transaction failing mid-way and error callback returning true");
88 failMidWay(function() { return false; });
89 verifySuccess("Testing transaction failing mid-way and error callback return false");
90 statementCallbackThrowsException(function() { return true; });
91 verifySuccess("Testing statement callback throwing exception and error callback returning true");
92 statementCallbackThrowsException(function() { return false; });
93 verifySuccess("Testing statement callback throwing exception and error callback returning false");
96 </script>
97 </head>
99 <body onload="runTest()">
100 This test confirms that <code>SQLTransactionErrorCallback</code> is invoked correctly and regardless of its output, the transaction is always rolled back on failure.
101 <pre id="console">
102 </pre>
103 </body>
105 </html>