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

Side by Side Diff: LayoutTests/fast/workers/storage/resources/sql-exception-codes-sync.js

Issue 561093003: Remove worker support of Web SQL Database. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 var dbName = "SQLExceptionCodesTest" + (new Date()).getTime();
2
3 function testTransaction(db, executeStatementsCallback, expectedError)
4 {
5 db.transaction(function(tx) {
6 try {
7 executeStatementsCallback(tx);
8 postMessage("FAIL: an exception (" + expectedError + ") should've be en thrown.");
9 } catch (err) {
10 postMessage("LOG: " + err);
11 if (typeof err == "string" && err == expectedError)
12 postMessage("PASS: expected and got error with message " + expec tedError);
13 else if (err.name == expectedError)
14 postMessage("PASS: expected and got error name " + expectedError );
15 else
16 postMessage("FAIL: expected error name " + expectedError + ", go t " + err);
17 }
18 });
19 }
20
21 function testTransactionThrowsException(db)
22 {
23 testTransaction(db, function(tx) { throw "Exception thrown in transaction ca llback."; }, "Exception thrown in transaction callback.");
24 }
25
26 function testInvalidStatement(db)
27 {
28 testTransaction(db, function(tx) { tx.executeSql("BAD STATEMENT"); }, "Synta xError");
29 }
30
31 function testIncorrectNumberOfBindParameters(db)
32 {
33 testTransaction(db,
34 function(tx) {
35 tx.executeSql("CREATE TABLE IF NOT EXISTS BadBindNumberT est (Foo INT, Bar INT)");
36 tx.executeSql("INSERT INTO BadBindNumberTest VALUES (?, ?)", [1]);
37 }, "SyntaxError");
38 }
39
40 function testBindParameterOfWrongType(db)
41 {
42 var badString = { };
43 badString.toString = function() { throw "Cannot call toString() on this obje ct." };
44
45 testTransaction(db, function(tx) {
46 tx.executeSql("CREATE TABLE IF NOT EXISTS BadBindTypeTest (Foo TEXT)");
47 tx.executeSql("INSERT INTO BadBindTypeTest VALUES (?)", [badString]);
48 }, "Cannot call toString() on this object.");
49 }
50
51 function testQuotaExceeded(db)
52 {
53 // Sometimes, SQLite automatically rolls back a transaction if executing a s tatement fails.
54 // This seems to be one of those cases.
55 try {
56 testTransaction(db,
57 function(tx) {
58 tx.executeSql("CREATE TABLE IF NOT EXISTS QuotaTest (Foo BLOB)");
59 tx.executeSql("INSERT INTO QuotaTest VALUES (ZEROBLO B(10 * 1024 * 1024))");
60 }, "QuotaExceededError");
61 postMessage("FAIL: Transaction should've been rolled back by SQLite.");
62 } catch (err) {
63 if (err.name == "DatabaseError")
64 postMessage("PASS: Transaction was rolled back by SQLite as expected .");
65 else
66 postMessage("FAIL: An unexpected exception was thrown: " + err);
67 }
68 }
69
70 function testVersionMismatch(db)
71 {
72 var db2 = openDatabaseSync(dbName, "1.0", "Tests the error codes.", 1);
73 db2.changeVersion("1.0", "2.0", function(tx) { });
74 testTransaction(db,
75 function(tx) {
76 tx.executeSql("THIS STATEMENT SHOULD NEVER GET EXECUTED" );
77 }, "VersionError");
78 }
79
80 var db = openDatabaseSync(dbName, "1.0", "Tests the exception codes.", 1);
81 testTransactionThrowsException(db);
82 testInvalidStatement(db);
83 testIncorrectNumberOfBindParameters(db);
84 testBindParameterOfWrongType(db);
85 testQuotaExceeded(db);
86 testVersionMismatch(db);
87
88 postMessage("done");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698