OLD | NEW |
1 <html> | 1 <html> |
2 | 2 |
3 <head> | 3 <head> |
| 4 <script src="execute-sql-args.js"></script> |
4 <script> | 5 <script> |
5 | 6 |
6 var throwOnToStringObject = { }; | 7 function log(message) |
7 throwOnToStringObject.toString = function () { throw "Cannot call toString on th
is object." }; | |
8 | |
9 var throwOnGetLengthObject = { }; | |
10 throwOnGetLengthObject.__defineGetter__("length", function () { throw "Cannot ge
t length of this object."; }); | |
11 | |
12 var throwOnGetZeroObject = { length: 1 }; | |
13 throwOnGetZeroObject.__defineGetter__("0", function () { throw "Cannot get 0 pro
perty of this object."; }); | |
14 | |
15 var expectNoException = [ | |
16 'null', | |
17 'undefined', | |
18 '0', | |
19 '""', | |
20 '"", null', | |
21 '"", undefined', | |
22 '"", []', | |
23 '"", [ "arg0" ]', | |
24 '"", { }', | |
25 '"", { length: 0 }', | |
26 '"", { length: 1, 0: "arg0" }', | |
27 '"", null, null', | |
28 '"", null, undefined', | |
29 '"", null, { }', | |
30 '"", null, null, null', | |
31 '"", null, null, undefined', | |
32 '"", null, null, { }', | |
33 ]; | |
34 | |
35 var expectException = [ | |
36 '', | |
37 'throwOnToStringObject', | |
38 '"", throwOnGetLengthObject', | |
39 '"", throwOnGetZeroObject', | |
40 '"", [ throwOnToStringObject ]', | |
41 '"", 0', | |
42 '"", ""', | |
43 '"", null, 0', | |
44 '"", null, ""', | |
45 '"", null, null, 0', | |
46 '"", null, null, ""', | |
47 ]; | |
48 | |
49 function writeMessageToLog(message) | |
50 { | 8 { |
51 document.getElementById("console").innerText += message + "\n"; | 9 document.getElementById("console").innerText += message + "\n"; |
52 } | 10 } |
53 | 11 |
54 function tryExecuteSql(transaction, parameterList) | 12 function setupAndRunTest() |
55 { | |
56 try { | |
57 eval('transaction.executeSql(' + parameterList + ')'); | |
58 return null; | |
59 } catch (exception) { | |
60 return exception; | |
61 } | |
62 } | |
63 | |
64 function runTransactionTest(transaction, parameterList, expectException) | |
65 { | |
66 var exception = tryExecuteSql(transaction, parameterList); | |
67 if (expectException) { | |
68 if (exception) | |
69 writeMessageToLog("PASS. executeSql(" + parameterList + ") threw an
exception as expected."); | |
70 else | |
71 writeMessageToLog("*FAIL*. executeSql(" + parameterList + ") did not
throw an exception"); | |
72 } else { | |
73 if (exception) | |
74 writeMessageToLog("*FAIL*. executeSql(" + parameterList + ") threw a
n exception: " + exception); | |
75 else | |
76 writeMessageToLog("PASS. executeSql(" + parameterList + ") did not t
hrow an exception"); | |
77 } | |
78 } | |
79 | |
80 function runTransactionTests(transaction) | |
81 { | |
82 for (i in expectNoException) | |
83 runTransactionTest(transaction, expectNoException[i], false); | |
84 for (i in expectException) | |
85 runTransactionTest(transaction, expectException[i], true); | |
86 | |
87 if (window.layoutTestController) | |
88 layoutTestController.notifyDone(); | |
89 } | |
90 | |
91 function runTest() | |
92 { | 13 { |
93 if (window.layoutTestController) { | 14 if (window.layoutTestController) { |
| 15 layoutTestController.clearAllDatabases(); |
94 layoutTestController.dumpAsText(); | 16 layoutTestController.dumpAsText(); |
95 layoutTestController.waitUntilDone(); | 17 layoutTestController.waitUntilDone(); |
96 } | 18 } |
97 | 19 runTest(); |
98 var db = openDatabase("ExecuteSQLArgsTest", "1.0", "Test of handling of the
arguments to SQLTransaction.executeSql", 1); | |
99 db.transaction(runTransactionTests); | |
100 } | 20 } |
101 | 21 |
102 </script> | 22 </script> |
103 </head> | 23 </head> |
104 | 24 |
105 <body onload="runTest()"> | 25 <body onload="setupAndRunTest()"> |
106 <pre id="console"></pre> | 26 <pre id="console"></pre> |
107 </body> | 27 </body> |
108 | 28 |
109 </html> | 29 </html> |
OLD | NEW |