| OLD | NEW |
| (Empty) |
| 1 var db; | |
| 2 | |
| 3 var notAString = { | |
| 4 toString: function() { throw "foo"; } | |
| 5 }; | |
| 6 | |
| 7 try { | |
| 8 db = openDatabaseSync(); | |
| 9 postMessage("FAIL: calling openDatabaseSync() without any argument should th
row an exception."); | |
| 10 } catch (err) { | |
| 11 postMessage("PASS: " + err.message); | |
| 12 } | |
| 13 | |
| 14 try { | |
| 15 db = openDatabaseSync("DBName", "DBVersion"); | |
| 16 postMessage("FAIL: calling openDatabaseSync() with fewer than four arguments
should throw an exception."); | |
| 17 } catch (err) { | |
| 18 postMessage("PASS: " + err.message); | |
| 19 } | |
| 20 | |
| 21 try { | |
| 22 db = openDatabaseSync(notAString, "DBVersion", "DBDescription", 1024); | |
| 23 postMessage("FAIL: the first argument to openDatabaseSync() must be a string
."); | |
| 24 } catch (err) { | |
| 25 postMessage("PASS: " + err.message); | |
| 26 } | |
| 27 | |
| 28 try { | |
| 29 db = openDatabaseSync("DBName", notAString, "DBDescription", 1024); | |
| 30 postMessage("FAIL: the second argument to openDatabaseSync() must be a strin
g."); | |
| 31 } catch (err) { | |
| 32 postMessage("PASS: " + err.message); | |
| 33 } | |
| 34 | |
| 35 try { | |
| 36 db = openDatabaseSync("DBName", "DBVersion", notAString, 1024); | |
| 37 postMessage("FAIL: the third argument to openDatabaseSync() must be a string
."); | |
| 38 } catch (err) { | |
| 39 postMessage("PASS: " + err.message); | |
| 40 } | |
| 41 | |
| 42 try { | |
| 43 db = openDatabaseSync("DBName", "DBVersion", "DBDescription", 1024, 0); | |
| 44 postMessage("FAIL: the fifth argument to openDatabaseSync() must be an objec
t, if present."); | |
| 45 } catch (err) { | |
| 46 postMessage("PASS: " + err.message); | |
| 47 } | |
| 48 | |
| 49 try { | |
| 50 db = openDatabaseSync("DBName", "DBVersion", "DBDescription", 1024); | |
| 51 postMessage("PASS: openDatabaseSync() succeeded."); | |
| 52 } catch (err) { | |
| 53 postMessage("FAIL: " + err.message); | |
| 54 } | |
| 55 | |
| 56 // Run this test case one more time, to test the code with an existing database. | |
| 57 try { | |
| 58 db = openDatabaseSync("DBName", "DBVersion", "DBDescription", 1024); | |
| 59 postMessage("PASS: openDatabaseSync() succeeded."); | |
| 60 } catch (err) { | |
| 61 postMessage("FAIL: " + err.message); | |
| 62 } | |
| 63 | |
| 64 try { | |
| 65 // Need to create a new database, otherwise the creation callback won't be i
nvoked. | |
| 66 db = openDatabaseSync("DBNameCreationCallback" + (new Date()).getTime(), "DB
Version", "DBDescription", 1024, | |
| 67 function(db) { | |
| 68 postMessage("PASS: calling openDatabaseSync() with
a creation callback succeeded."); | |
| 69 }); | |
| 70 } catch (err) { | |
| 71 postMessage("FAIL: " + err.message); | |
| 72 } | |
| 73 | |
| 74 postMessage("done"); | |
| OLD | NEW |