6 var throwOnToStringObject = { };
7 throwOnToStringObject.toString = function () { throw "Cannot call toString on this object." };
9 var throwOnGetLengthObject = { };
10 throwOnGetLengthObject.__defineGetter__("length", function () { throw "Cannot get length of this object."; });
12 var throwOnGetZeroObject = { length: 1 };
13 throwOnGetZeroObject.__defineGetter__("0", function () { throw "Cannot get 0 property of this object."; });
15 var expectNoException = [
27 '"", { length: 1, 0: "arg0" }',
29 '"", null, undefined',
31 '"", null, null, null',
32 '"", null, null, undefined',
33 '"", null, null, { }',
36 var expectException = [
37 'throwOnToStringObject',
38 '"", throwOnGetLengthObject',
39 '"", throwOnGetZeroObject',
40 '"", [ throwOnToStringObject ]',
49 function writeMessageToLog(message)
51 document.getElementById("console").innerText += message + "\n";
54 function tryExecuteSql(transaction, parameterList)
57 eval('transaction.executeSql(' + parameterList + ')');
64 function runTransactionTest(transaction, parameterList, expectException)
66 var exception = tryExecuteSql(transaction, parameterList);
67 if (expectException) {
69 writeMessageToLog("PASS. executeSql(" + parameterList + ") threw an exception as expected: " + exception);
71 writeMessageToLog("*FAIL*. executeSql(" + parameterList + ") did not throw an exception");
74 writeMessageToLog("*FAIL*. executeSql(" + parameterList + ") threw an exception: " + exception);
76 writeMessageToLog("PASS. executeSql(" + parameterList + ") did not throw an exception");
80 function runTransactionTests(transaction)
82 for (i in expectNoException)
83 runTransactionTest(transaction, expectNoException[i], false);
84 for (i in expectException)
85 runTransactionTest(transaction, expectException[i], true);
87 if (window.layoutTestController)
88 layoutTestController.notifyDone();
92 if (window.layoutTestController) {
93 layoutTestController.dumpAsText();
94 layoutTestController.waitUntilDone();
97 var db = openDatabase("ExecuteSQLArgsTest", "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1);
98 db.transaction(runTransactionTests);
104 <body onload="runTest()">
105 <pre id="console"></pre>