summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/statement-error-callback.html
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/storage/statement-error-callback.html')
-rw-r--r--LayoutTests/storage/statement-error-callback.html68
1 files changed, 68 insertions, 0 deletions
diff --git a/LayoutTests/storage/statement-error-callback.html b/LayoutTests/storage/statement-error-callback.html
new file mode 100644
index 0000000..3675548
--- /dev/null
+++ b/LayoutTests/storage/statement-error-callback.html
@@ -0,0 +1,68 @@
+<html>
+<head>
+<script>
+
+function log(message)
+{
+ document.getElementById("console").innerHTML += message + "<br>";
+}
+
+function finishTest()
+{
+ log("Test Complete");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+var txCallbackCount = 0;
+var NUMBER_OF_TRANSACTIONS = 2;
+
+function transactionErrorFunction(error)
+{
+ log("PASS - the transaction error callback was invoked.");
+ if (++txCallbackCount == NUMBER_OF_TRANSACTIONS)
+ finishTest();
+}
+
+function transactionSuccessFunction(message)
+{
+ log("FAIL - the transaction success callback should not be invoked.");
+ if (++txCallbackCount == NUMBER_OF_TRANSACTIONS)
+ finishTest();
+}
+
+function runTest()
+{
+ if (window.layoutTestController) {
+ layoutTestController.clearAllDatabases();
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ var database = openDatabase("bug-28872", "1.0", "statement error callback test", 1024);
+
+ database.transaction(function(tx) {
+ tx.executeSql("CREATE TABLE IF NOT EXISTS StatementErrorCallbackTest (randomData)");
+ tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test']);
+ tx.executeSql("THIS STATEMENT WILL FAIL", [], function(message) { log("FAIL - this statement should have failed"); finishTest(); }, function(error) { return true; });
+ tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test1'], function(message) { log("FAIL - This statement should not have been executed"); }, function(message) { log("FAIL - This statement should not have been executed"); });
+ }, transactionErrorFunction, transactionSuccessFunction);
+
+ database.transaction(function(tx) {
+ tx.executeSql("CREATE TABLE IF NOT EXISTS StatementErrorCallbackTest (randomData)");
+ tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test']);
+ tx.executeSql("THIS STATEMENT WILL FAIL", [], function(message) { log("FAIL - this statement should have failed"); finishTest(); }, function(error) { throw "Exception in Statement error callback"; return false; });
+ tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test1'], function(message) { log("FAIL - This statement should not have been executed"); }, function(message) { log("FAIL - This statement should not have been executed"); });
+ }, transactionErrorFunction, transactionSuccessFunction);
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+This test confirms that if the statement error callback returns true or throws an exception we do not execute any further statements in that transaction and instead execute the transaction error callback immediately.
+<pre id="console">
+</pre>
+</body>
+
+</html>