Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: LayoutTests/storage/execute-sql-args.js

Issue 598034: Refactor a database test such that its code can be shared between the documen... (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 var throwOnToStringObject = { };
2 throwOnToStringObject.toString = function () { throw "Cannot call toString on th is object." };
3
4 var throwOnGetLengthObject = { };
5 throwOnGetLengthObject.__defineGetter__("length", function () { throw "Cannot ge t length of this object."; });
6
7 var throwOnGetZeroObject = { length: 1 };
8 throwOnGetZeroObject.__defineGetter__("0", function () { throw "Cannot get 0 pro perty of this object."; });
9
10 var expectNoException = [
11 'null',
12 'undefined',
13 '0',
14 '""',
15 '"", null',
16 '"", undefined',
17 '"", []',
18 '"", [ "arg0" ]',
19 '"", { }',
20 '"", { length: 0 }',
21 '"", { length: 1, 0: "arg0" }',
22 '"", null, null',
23 '"", null, undefined',
24 '"", null, { }',
25 '"", null, null, null',
26 '"", null, null, undefined',
27 '"", null, null, { }',
28 ];
29
30 var expectException = [
31 '',
32 'throwOnToStringObject',
33 '"", throwOnGetLengthObject',
34 '"", throwOnGetZeroObject',
35 '"", [ throwOnToStringObject ]',
36 '"", 0',
37 '"", ""',
38 '"", null, 0',
39 '"", null, ""',
40 '"", null, null, 0',
41 '"", null, null, ""',
42 ];
43
44 function tryExecuteSql(transaction, parameterList)
45 {
46 try {
47 eval('transaction.executeSql(' + parameterList + ')');
48 return null;
49 } catch (exception) {
50 return exception;
51 }
52 }
53
54 function runTransactionTest(transaction, parameterList, expectException)
55 {
56 var exception = tryExecuteSql(transaction, parameterList);
57 if (expectException) {
58 if (exception)
59 log("PASS. executeSql(" + parameterList + ") threw an exception as e xpected.");
60 else
61 log("*FAIL*. executeSql(" + parameterList + ") did not throw an exce ption");
62 } else {
63 if (exception)
64 log("*FAIL*. executeSql(" + parameterList + ") threw an exception: " + exception);
65 else
66 log("PASS. executeSql(" + parameterList + ") did not throw an except ion");
67 }
68 }
69
70 function runTransactionTests(transaction)
71 {
72 for (i in expectNoException)
73 runTransactionTest(transaction, expectNoException[i], false);
74 for (i in expectException)
75 runTransactionTest(transaction, expectException[i], true);
76
77 if (window.layoutTestController)
78 layoutTestController.notifyDone();
79 }
80
81 function runTest()
82 {
83
84 var db = openDatabase("ExecuteSQLArgsTest", "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1);
85 db.transaction(runTransactionTests);
86 }
87
88
OLDNEW
« no previous file with comments | « LayoutTests/storage/execute-sql-args.html ('k') | LayoutTests/storage/execute-sql-args-worker.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698