1 var throwOnToStringObject = { };
2 throwOnToStringObject.toString = function () { throw "Cannot call toString on this object." };
4 var throwOnGetLengthObject = { };
5 throwOnGetLengthObject.__defineGetter__("length", function () { throw "Cannot get length of this object."; });
7 var throwOnGetZeroObject = { length: 1 };
8 throwOnGetZeroObject.__defineGetter__("0", function () { throw "Cannot get 0 property of this object."; });
10 var expectNoException = [
18 '"", { length: 1, 0: "arg0" }',
21 var expectException = [
26 'throwOnToStringObject',
27 '"", throwOnGetLengthObject',
28 '"", throwOnGetZeroObject',
29 '"", [ throwOnToStringObject ]',
34 function tryExecuteSql(transaction, parameterList)
37 eval('transaction.executeSql(' + parameterList + ')');
44 function runTransactionTest(transaction, parameterList, expectException)
46 var exception = tryExecuteSql(transaction, parameterList);
47 if (expectException) {
49 postMessage("PASS: executeSql(" + parameterList + ") threw an exception as expected.");
51 postMessage("FAIL: executeSql(" + parameterList + ") did not throw an exception.");
54 postMessage("FAIL: executeSql(" + parameterList + ") threw an exception: " + exception);
56 postMessage("PASS: executeSql(" + parameterList + ") did not throw an exception.");
60 function runTransactionTests(transaction)
62 for (i in expectNoException)
63 runTransactionTest(transaction, expectNoException[i], false);
64 for (i in expectException)
65 runTransactionTest(transaction, expectException[i], true);
68 var db = openDatabaseSync("ExecuteSQLArgsTest", "1.0", "Test of handling of the arguments to SQLTransactionSync.executeSql", 1);
69 db.transaction(runTransactionTests);