summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/statement-error-callback.html
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-04-27 16:23:55 +0100
committerSteve Block <steveblock@google.com>2010-04-27 17:07:03 +0100
commit692e5dbf12901edacf14812a6fae25462920af42 (patch)
treed62802373a429e0a9dc093b6046c166b2c514285 /LayoutTests/storage/statement-error-callback.html
parente24bea4efef1c414137d36a9778aa4e142e10c7d (diff)
downloadexternal_webkit-692e5dbf12901edacf14812a6fae25462920af42.zip
external_webkit-692e5dbf12901edacf14812a6fae25462920af42.tar.gz
external_webkit-692e5dbf12901edacf14812a6fae25462920af42.tar.bz2
Merge webkit.org at r55033 : Initial merge by git
Change-Id: I98a4af828067cc243ec3dc5e5826154dd88074b5
Diffstat (limited to 'LayoutTests/storage/statement-error-callback.html')
-rw-r--r--LayoutTests/storage/statement-error-callback.html56
1 files changed, 40 insertions, 16 deletions
diff --git a/LayoutTests/storage/statement-error-callback.html b/LayoutTests/storage/statement-error-callback.html
index 3675548..060a881 100644
--- a/LayoutTests/storage/statement-error-callback.html
+++ b/LayoutTests/storage/statement-error-callback.html
@@ -15,7 +15,8 @@ function finishTest()
}
var txCallbackCount = 0;
-var NUMBER_OF_TRANSACTIONS = 2;
+var NUMBER_OF_TRANSACTIONS = 7;
+var database;
function transactionErrorFunction(error)
{
@@ -31,6 +32,22 @@ function transactionSuccessFunction(message)
finishTest();
}
+function runTransactionExpectedToFail(statementErrorCallback)
+{
+ 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(tx, data) {
+ log("FAIL - this statement should have failed");
+ finishTest();
+ }, statementErrorCallback);
+ tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test1'],
+ function(error) { log("FAIL - This statement should not have been executed"); },
+ function() { log("FAIL - This statement should not have been executed"); });
+ }, transactionErrorFunction, transactionSuccessFunction);
+}
+
function runTest()
{
if (window.layoutTestController) {
@@ -38,29 +55,36 @@ function runTest()
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) {
+ 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) { 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);
+ tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test']);
+ tx.executeSql("THIS STATEMENT WILL FAIL", [],
+ function(tx, data) {
+ log("FAIL - this statement should have failed");
+ finishTest();
+ }, function(tx, error) { return false; });
+ tx.executeSql("INSERT INTO StatementErrorCallbackTest (randomData) VALUES (?)", ['test1'],
+ function(tx, data) { },
+ function(tx, error) { log("FAIL - This statement should not have caused an error"); });
+ }, function(error) { log("FAIL - The transaction error callback should not have been invoked"); },
+ function() { });
+
+ runTransactionExpectedToFail(function(error) { return true; });
+ runTransactionExpectedToFail(function(error) { throw "Exception in statement error callback"; return false; });
+ runTransactionExpectedToFail(function(error) {});
+ runTransactionExpectedToFail(function(error) { return null; });
+ runTransactionExpectedToFail(function(error) { return "some string"; });
+ runTransactionExpectedToFail(function(error) { return 1234; });
+ runTransactionExpectedToFail(function(error) { return {a: 2, b: "abc"}; });
}
</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.
+This test confirms that a transaction is immediately rolled back if and only if a statement's error callback throws an exception, returns true, or doesn't return any value.
<pre id="console">
</pre>
</body>