5 var TOTAL_STATEMENTS
= 8;
11 document
.body
.innerText
+= message
+ "\n";
14 function terminateTest()
16 if (window
.testRunner
)
17 testRunner
.notifyDone();
20 function executeStatement(expectedToPass
, statement
)
22 db
.transaction(function(tx
) {
23 tx
.executeSql(statement
, [],
25 if (!expectedToPass
) {
26 log("Statement " + statement
+ " was expected to fail, but passed.");
29 if (++statements
== TOTAL_STATEMENTS
) {
33 }, function(tx
, error
) {
35 log("Statement " + statement
+ " was expected to pass, but failed.");
38 if (++statements
== TOTAL_STATEMENTS
) {
48 if (window
.testRunner
) {
49 testRunner
.clearAllDatabases();
50 testRunner
.dumpAsText();
51 testRunner
.waitUntilDone();
54 db
= openDatabase("ExecuteSQLAcceptsOnlyOneStatementTest", "1.0", "", 1);
55 db
.transaction(function(tx
) {
56 tx
.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo INT)");
58 log("Test failed: " + error
.message
);
61 executeStatement(true, "INSERT INTO Test VALUES (1)");
62 executeStatement(true, "INSERT INTO Test VALUES (2);");
63 executeStatement(true, " INSERT INTO Test VALUES (3) ");
64 executeStatement(true, " INSERT INTO Test VALUES (4); ");
65 executeStatement(true, "INSERT INTO Test VALUES (5) ;");
66 executeStatement(false, "INSERT INTO Test VALUES (6); garbage");
67 executeStatement(false, "INSERT INTO Test VALUES (7); INSERT INTO Test VALUES (8)");
68 executeStatement(false, " INSERT INTO Test VALUES (9); INSERT INTO Test VALUES (10); ");
74 <body onload=
"runTest();">
75 This test tests that executeSql() fails when called with a string that has more than one valid statement in it.
<br>