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 = [
21 '"", { length: 1, 0: "arg0" }',
23 '"", null, undefined',
25 '"", null, null, null',
26 '"", null, null, undefined',
27 '"", null, null, { }',
30 var expectException = [
32 'throwOnToStringObject',
33 '"", throwOnGetLengthObject',
34 '"", throwOnGetZeroObject',
35 '"", [ throwOnToStringObject ]',
44 function tryExecuteSql(transaction, parameterList)
47 eval('transaction.executeSql(' + parameterList + ')');
54 function runTransactionTest(transaction, parameterList, expectException)
56 var exception = tryExecuteSql(transaction, parameterList);
57 if (expectException) {
59 log("PASS. executeSql(" + parameterList + ") threw an exception as expected.");
61 log("*FAIL*. executeSql(" + parameterList + ") did not throw an exception");
64 log("*FAIL*. executeSql(" + parameterList + ") threw an exception: " + exception);
66 log("PASS. executeSql(" + parameterList + ") did not throw an exception");
70 function runTransactionTests(transaction)
72 for (i in expectNoException)
73 runTransactionTest(transaction, expectNoException[i], false);
74 for (i in expectException)
75 runTransactionTest(transaction, expectException[i], true);
77 if (window.layoutTestController)
78 layoutTestController.notifyDone();
84 var db = openDatabaseWithSuffix("ExecuteSQLArgsTest", "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1);
85 db.transaction(runTransactionTests);