1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
var throwOnToStringObject = { };
throwOnToStringObject.toString = function () { throw "Cannot call toString on this object." };
var throwOnGetLengthObject = { };
throwOnGetLengthObject.__defineGetter__("length", function () { throw "Cannot get length of this object."; });
var throwOnGetZeroObject = { length: 1 };
throwOnGetZeroObject.__defineGetter__("0", function () { throw "Cannot get 0 property of this object."; });
var expectNoException = [
'null',
'undefined',
'0',
'""',
'"", null',
'"", undefined',
'"", []',
'"", [ "arg0" ]',
'"", { }',
'"", { length: 0 }',
'"", { length: 1, 0: "arg0" }',
'"", null, null',
'"", null, undefined',
'"", null, { }',
'"", null, null, null',
'"", null, null, undefined',
'"", null, null, { }',
];
var expectException = [
'',
'throwOnToStringObject',
'"", throwOnGetLengthObject',
'"", throwOnGetZeroObject',
'"", [ throwOnToStringObject ]',
'"", 0',
'"", ""',
'"", null, 0',
'"", null, ""',
'"", null, null, 0',
'"", null, null, ""',
];
function tryExecuteSql(transaction, parameterList)
{
try {
eval('transaction.executeSql(' + parameterList + ')');
return null;
} catch (exception) {
return exception;
}
}
function runTransactionTest(transaction, parameterList, expectException)
{
var exception = tryExecuteSql(transaction, parameterList);
if (expectException) {
if (exception)
log("PASS. executeSql(" + parameterList + ") threw an exception as expected.");
else
log("*FAIL*. executeSql(" + parameterList + ") did not throw an exception");
} else {
if (exception)
log("*FAIL*. executeSql(" + parameterList + ") threw an exception: " + exception);
else
log("PASS. executeSql(" + parameterList + ") did not throw an exception");
}
}
function runTransactionTests(transaction)
{
for (i in expectNoException)
runTransactionTest(transaction, expectNoException[i], false);
for (i in expectException)
runTransactionTest(transaction, expectException[i], true);
if (window.layoutTestController)
layoutTestController.notifyDone();
}
function runTest()
{
var db = openDatabaseWithSuffix("ExecuteSQLArgsTest", "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1);
db.transaction(runTransactionTests);
}
|