summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/transaction-error-callback.html
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-02-25 10:58:37 +0000
committerSteve Block <steveblock@google.com>2010-02-25 11:17:52 +0000
commitcfb0617749a64f2e177386b030d46007b8c4b179 (patch)
tree033b0b4e1b1eaa96831b52fc1ec6675132f33035 /LayoutTests/storage/transaction-error-callback.html
parent4175d59b46f96005f0c64978b1a94e3fe60f1e8e (diff)
downloadexternal_webkit-cfb0617749a64f2e177386b030d46007b8c4b179.zip
external_webkit-cfb0617749a64f2e177386b030d46007b8c4b179.tar.gz
external_webkit-cfb0617749a64f2e177386b030d46007b8c4b179.tar.bz2
Adds layout tests for HTML5 features
The following layout tests should all pass on Android, as they are for recently implemented HTML5 features ... - fast/dom/Geolocation - storage - http/tests/appcache This change adds these tests to the Android tree, at the current WebKit revision r54731. This is so that we can easily keep track of which tests should always be green, and so that we can add Android-specific test results. We also add the following paths ... - fast/js/resources - used by the Geolocation tests - http/conf - used by the Appcache tests Tests that are currently failing are added to the DumpRenderTree skipped list temporarily, to keep all tests green. Change-Id: Id96c05e3746ed64e4e4c40c99567b8def688f90a
Diffstat (limited to 'LayoutTests/storage/transaction-error-callback.html')
-rw-r--r--LayoutTests/storage/transaction-error-callback.html105
1 files changed, 105 insertions, 0 deletions
diff --git a/LayoutTests/storage/transaction-error-callback.html b/LayoutTests/storage/transaction-error-callback.html
new file mode 100644
index 0000000..90b2ed0
--- /dev/null
+++ b/LayoutTests/storage/transaction-error-callback.html
@@ -0,0 +1,105 @@
+<html>
+<head>
+<script>
+
+function log(message)
+{
+ document.getElementById("console").innerHTML += message + "<br>";
+}
+
+// signal to layoutTestController when this reaches zero.
+var testCount = 4;
+// we first retrieve and store the number of rows already in our test database.
+// our goal is to keep the number unchanged through the tests.
+var initialRowCount = 0;
+var database;
+var successCallbackCalled;
+
+function finishTest()
+{
+ if (--testCount)
+ return;
+
+ log("All Tests are complete.");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function successCallback()
+{
+ successCallbackCalled = true;
+}
+
+function verifySuccess(msg)
+{
+ database.transaction(function(tx)
+ {
+ tx.executeSql("SELECT count(*) AS count FROM ErrorCallbackTest", [], function(tx, rs)
+ {
+ log(msg + " : " + (rs.rows.item(0).count == initialRowCount && !successCallbackCalled ? "SUCCESS" : "FAILURE"));
+ finishTest();
+ });
+ });
+}
+
+function failMidWay(errorCallback)
+{
+ successCallbackCalled = false;
+ database.transaction(function(tx)
+ {
+ tx.executeSql("INSERT INTO ErrorCallbackTest(someValue) VALUES(?);", [ 1 ]);
+ tx.executeSql("MUTTER SOMETHING ILLEGIBLE");
+ }, errorCallback, successCallback);
+}
+
+function statementCallbackThrowsException(errorCallback)
+{
+ successCallbackCalled = false;
+ database.transaction(function(tx)
+ {
+ tx.executeSql("INSERT INTO ErrorCallbackTest(someValue) VALUES(?);", [ 1 ], function()
+ {
+ throw {};
+ });
+ });
+}
+
+function runTest()
+{
+ if (window.layoutTestController) {
+ layoutTestController.clearAllDatabases();
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ database = openDatabase("ErrorCallbackDatabase", "1.0", "Test for error callback", 1);
+ database.transaction(function(tx)
+ {
+ tx.executeSql("CREATE TABLE IF NOT EXISTS ErrorCallbackTest (someValue)", []);
+ tx.executeSql("SELECT count(*) AS count FROM ErrorCallbackTest", [], function(tx, rs)
+ {
+ initialRowCount = rs.rows.item(0).count;
+ });
+ });
+
+ failMidWay(function() { return true; });
+ verifySuccess("Testing transaction failing mid-way and error callback returning true");
+ failMidWay(function() { return false; });
+ verifySuccess("Testing transaction failing mid-way and error callback return false");
+ statementCallbackThrowsException(function() { return true; });
+ verifySuccess("Testing statement callback throwing exception and error callback returning true");
+ statementCallbackThrowsException(function() { return false; });
+ verifySuccess("Testing statement callback throwing exception and error callback returning false");
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+This test confirms that <code>SQLTransactionErrorCallback</code> is invoked correctly and regardless of its output, the transaction is always rolled back on failure.
+<pre id="console">
+</pre>
+</body>
+
+</html>