| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <head> | |
| 3 <script> | |
| 4 var database1 = null; | |
| 5 var database2 = null; | |
| 6 var database3 = null; | |
| 7 | |
| 8 function log(message) | |
| 9 { | |
| 10 document.getElementById("console").innerHTML += message + "<br>"; | |
| 11 } | |
| 12 | |
| 13 function finishTest() | |
| 14 { | |
| 15 log("Test Complete"); | |
| 16 if (window.testRunner) | |
| 17 testRunner.notifyDone(); | |
| 18 } | |
| 19 | |
| 20 function statementErrorFunction(tx, error) | |
| 21 { | |
| 22 log("Unexpected exception - " + error.message); | |
| 23 finishTest(); | |
| 24 } | |
| 25 | |
| 26 function transactionErrorFunction(db, error) | |
| 27 { | |
| 28 // We only expect an error message for database2 | |
| 29 if (db == database2) { | |
| 30 log("Expected quota exception - " + error.message); | |
| 31 checkCompletion(db); | |
| 32 } else { | |
| 33 log("Unexpected exception - " + error.message); | |
| 34 finishTest(); | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 function checkCompletion(db) | |
| 39 { | |
| 40 log("Done adding data"); | |
| 41 | |
| 42 if (database3) { | |
| 43 finishTest(); | |
| 44 } else if (database2) { | |
| 45 database3 = openDatabase("QuotaManagementDatabase3", "1.0", "Test for qu
ota management <rdar://5628468>", 1); | |
| 46 testDatabase(database3); | |
| 47 } else { | |
| 48 database2 = openDatabase("QuotaManagementDatabase2", "1.0", "Test for qu
ota management <rdar://5628468>", 1); | |
| 49 testDatabase(database2); | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 function addData(db) | |
| 54 { | |
| 55 db.transaction(function(tx) { | |
| 56 log("Inserting some data"); | |
| 57 tx.executeSql("INSERT INTO DataTest (randomData) VALUES (ZEROBLOB(17408)
)", [], | |
| 58 function(tx, result) { }, statementErrorFunction); | |
| 59 if (db == database2) { | |
| 60 // Try to run this statement on 'database2' only. | |
| 61 // It should not be run, because the previous statement should've | |
| 62 // resulted in a failure that made sqlite roll back the entire trans
action. | |
| 63 tx.executeSql("INSERT INTO DataTest (randomData) VALUES (ZEROBLOB(10
))", [], | |
| 64 function(tx, result) { | |
| 65 log("This statement should not have been run."); | |
| 66 finishTest(); | |
| 67 }, statementErrorFunction); | |
| 68 } | |
| 69 }, function(error) { | |
| 70 transactionErrorFunction(db, error); | |
| 71 }, function() { | |
| 72 checkCompletion(db); | |
| 73 }); | |
| 74 } | |
| 75 | |
| 76 function testDatabase(db) | |
| 77 { | |
| 78 db.transaction(function(tx) { | |
| 79 log("Adding a table"); | |
| 80 tx.executeSql("CREATE TABLE DataTest (randomData)", [], | |
| 81 function(tx, result) { }, statementErrorFunction); | |
| 82 }, function(error) { | |
| 83 transactionErrorFunction(db, error); | |
| 84 }, function() { | |
| 85 addData(db); | |
| 86 }); | |
| 87 } | |
| 88 | |
| 89 function runTest() | |
| 90 { | |
| 91 if (window.testRunner) { | |
| 92 testRunner.clearAllDatabases(); | |
| 93 testRunner.dumpDatabaseCallbacks(); | |
| 94 testRunner.setDatabaseQuota(40960); | |
| 95 testRunner.dumpAsText(); | |
| 96 testRunner.waitUntilDone(); | |
| 97 } | |
| 98 | |
| 99 database1 = openDatabase("QuotaManagementDatabase1", "1.0", "Test for quota
management <rdar://5628468>", 1); | |
| 100 testDatabase(database1); | |
| 101 } | |
| 102 | |
| 103 </script> | |
| 104 </head> | |
| 105 | |
| 106 <body onload="runTest()"> | |
| 107 This test checks to make sure that quotas are enforced per-origin instead of per
-database, as they were prior to http://trac.webkit.org/projects/webkit/changese
t/29983.<br> | |
| 108 The test clears all databases, sets the quota for the origin to 40k, then tries
to insert 17k of data into two databases. If things go as planned, the second in
sert should fail, the UI Delegate should be informed of the exceeded quota and s
hould increase the quota for this origin. Inserting 17k of data the third time s
hould succeed again. | |
| 109 <pre id="console"> | |
| 110 </pre> | |
| 111 </body> | |
| 112 | |
| 113 </html> | |
| OLD | NEW |