diff options
Diffstat (limited to 'LayoutTests/storage/executesql-accepts-only-one-statement.html')
-rw-r--r-- | LayoutTests/storage/executesql-accepts-only-one-statement.html | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/LayoutTests/storage/executesql-accepts-only-one-statement.html b/LayoutTests/storage/executesql-accepts-only-one-statement.html new file mode 100644 index 0000000..a3860c8 --- /dev/null +++ b/LayoutTests/storage/executesql-accepts-only-one-statement.html @@ -0,0 +1,78 @@ +<html> +<head> +<script> + +var TOTAL_STATEMENTS = 8; +var statements = 0; +var db = null; + +function log(message) +{ + document.body.innerText += message + "\n"; +} + +function terminateTest() +{ + if (window.layoutTestController) + layoutTestController.notifyDone(); +} + +function executeStatement(expectedToPass, statement) +{ + db.transaction(function(tx) { + tx.executeSql(statement, [], + function(tx, data) { + if (!expectedToPass) { + log("Statement " + statement + " was expected to fail, but passed."); + terminateTest(); + } + if (++statements == TOTAL_STATEMENTS) { + log("Test passed."); + terminateTest(); + } + }, function(tx, error) { + if (expectedToPass) { + log("Statement " + statement + " was expected to pass, but failed."); + terminateTest(); + } + if (++statements == TOTAL_STATEMENTS) { + log("Test passed."); + terminateTest(); + } + }); + }); +} + +function runTest() +{ + if (window.layoutTestController) { + layoutTestController.clearAllDatabases(); + layoutTestController.dumpAsText(); + layoutTestController.waitUntilDone(); + } + + db = openDatabase("ExecuteSQLAcceptsOnlyOneStatementTest", "1.0", "", 1); + db.transaction(function(tx) { + tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo INT)"); + }, function(error) { + log("Test failed: " + error.message); + terminateTest(); + }, function() { + executeStatement(true, "INSERT INTO Test VALUES (1)"); + executeStatement(true, "INSERT INTO Test VALUES (2);"); + executeStatement(true, " INSERT INTO Test VALUES (3) "); + executeStatement(true, " INSERT INTO Test VALUES (4); "); + executeStatement(true, "INSERT INTO Test VALUES (5) ;"); + executeStatement(false, "INSERT INTO Test VALUES (6); garbage"); + executeStatement(false, "INSERT INTO Test VALUES (7); INSERT INTO Test VALUES (8)"); + executeStatement(false, " INSERT INTO Test VALUES (9); INSERT INTO Test VALUES (10); "); + }); +} + +</script> +</head> +<body onload="runTest();"> +This test tests that executeSql() fails when called with a string that has more than one valid statement in it.<br> +</body> +</body> +</html> |