Changeset 60387 in webkit
- Timestamp:
- May 28, 2010 8:45:50 PM (14 years ago)
- Location:
- trunk/LayoutTests
- Files:
-
- 14 added
- 17 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r60386 r60387 1 2010-05-28 Eric Uhrhane <ericu@chromium.org> 2 3 Reviewed by Dmitry Titov. 4 5 Refactor DB layout tests so that they work in Web Workers as well as Pages. 6 This is a big set of ports, but there are still more to come. 7 In general, this is all just trivial changes. For each test file, I pull out the meat into a .js file [with no functional changes]. Then I include that from both the DOM test and a new worker test; in both cases, the .html files are trivial wrappers. All boilerplate code is pulled out into the resource files. 8 9 In a couple of these tests, there were try/catch wrappers that suppressed errors. I don't see why you'd want to do that in a test; let's let those errors cause test failures, then fix them. I took out the wrappers and saw no difference in behavior. 10 11 https://bugs.webkit.org/show_bug.cgi?id=34995 12 13 * fast/workers/storage/multiple-databases-garbage-collection-expected.txt: Added. 14 * fast/workers/storage/multiple-databases-garbage-collection.html: Added. 15 * fast/workers/storage/multiple-transactions-expected.txt: Added. 16 * fast/workers/storage/multiple-transactions.html: Added. 17 * fast/workers/storage/multiple-transactions-on-different-handles-expected.txt: Added. 18 * fast/workers/storage/multiple-transactions-on-different-handles.html: Added. 19 * fast/workers/storage/change-version-handle-reuse-worker.html: Pulled out even more boilerplate. 20 * fast/workers/storage/execute-sql-args-worker.html: Pulled out even more boilerplate. 21 * fast/workers/storage/resources/database-worker-controller: Here's where the boilerplate went. 22 * fast/workers/storage/resources/database-worker.js: 23 * storage/multiple-databases-garbage-collection.html: 24 * storage/multiple-databases-garbage-collection.js: Added. 25 * storage/multiple-transactions-on-different-handles.html: 26 * storage/multiple-transactions-on-different-handles.js: Added. 27 * storage/multiple-transactions.html: 28 * storage/multiple-transactions.js: Added. 29 * storage/hash-change-with-xhr-expected.txt: Trivial whitespace change. 30 * storage/hash-change-with-xhr.html: 31 * storage/hash-change-with-xhr.js: Added. 32 * storage/open-database-while-transaction-in-progress.html: 33 * storage/open-database-while-transaction-in-progress.js: Added. 34 * storage/read-and-write-transactions-dont-run-together.html: 35 * storage/read-and-write-transactions-dont-run-together.js: Added. 36 * storage/test-authorizer.html: 37 * storage/test-authorizer.js: Added. 38 I made a small common include for all the non-worker tests to remove a little boilerplate. 39 * storage/resources/database-common.js: Added. 40 These two tests had already been ported to workers; I updated them to use the common include file. 41 * storage/change-version-handle-reuse.html: 42 * storage/execute-sql-args.html: 43 * fast/workers/storage/open-database-while-transaction-in-progress-expected.txt: Added. 44 * fast/workers/storage/open-database-while-transaction-in-progress.html: Added. 45 * fast/workers/storage/read-and-write-transactions-dont-run-together-expected.txt: Added. 46 * fast/workers/storage/read-and-write-transactions-dont-run-together.html: Added. 47 * fast/workers/storage/test-authorizer-expected.txt: Added. 48 * fast/workers/storage/test-authorizer.html: Added. 49 1 50 2010-05-28 Eric Uhrhane <ericu@chromium.org> 2 51 -
trunk/LayoutTests/fast/workers/storage/change-version-handle-reuse-worker.html
r59540 r60387 2 2 <head> 3 3 <script src="resources/database-worker-controller.js"></script> 4 <script>5 6 function setupAndRunTest()7 {8 if (window.layoutTestController) {9 layoutTestController.waitUntilDone();10 layoutTestController.dumpAsText();11 }12 13 document.getElementById("console").innerText = "";14 databaseWorker.postMessage("importScripts:../../../storage/change-version-handle-reuse.js");15 databaseWorker.postMessage("runTest");16 }17 </script>18 4 </head> 19 <body onload=" setupAndRunTest()">5 <body onload="runTest('change-version-handle-reuse.js')"> 20 6 <div>This tests that a database can be accessed after changing its version. You should see an error about FooBar table below, not about mismatching versions. 21 7 <pre id="console"> -
trunk/LayoutTests/fast/workers/storage/execute-sql-args-worker.html
r59540 r60387 2 2 <head> 3 3 <script src="resources/database-worker-controller.js"></script> 4 <script>5 6 function setupAndRunTest()7 {8 if (window.layoutTestController) {9 layoutTestController.dumpAsText();10 layoutTestController.waitUntilDone();11 }12 databaseWorker.postMessage("importScripts:../../../storage/execute-sql-args.js");13 databaseWorker.postMessage("runTest");14 }15 16 </script>17 4 </head> 18 5 19 <body onload="setupAndRunTest()"> 20 <pre id="console"></pre> 6 <body onload="runTest('execute-sql-args.js')"> 7 <pre id="console"> 8 FAILURE: test didn't run. 9 </pre> 21 10 </body> 22 11 -
trunk/LayoutTests/fast/workers/storage/resources/database-worker-controller.js
r59540 r60387 9 9 10 10 databaseWorker.onmessage = function(event) { 11 if (event.data.indexOf('log:') == 0) 11 if (event.data.indexOf('log:') == 0) { 12 12 log(event.data.substring(4)); 13 else if (event.data == 'notifyDone') {13 } else if (event.data == 'notifyDone') { 14 14 if (window.layoutTestController) 15 15 layoutTestController.notifyDone(); 16 } else if (event.data.indexOf('setLocationHash:') == '0') { 17 location.hash = event.data.substring('setLocationHash:'.length); 18 } else if (event.data == 'back') { 19 history.back(); 16 20 } else 17 21 throw new Error("Unrecognized message: " + event); … … 22 26 document.getElementById("console").innerText += message + "\n"; 23 27 } 28 29 function runTest(testFile) 30 { 31 if (window.layoutTestController) { 32 layoutTestController.dumpAsText(); 33 layoutTestController.waitUntilDone(); 34 } 35 document.getElementById("console").innerText = ""; 36 databaseWorker.postMessage("importScripts:../../../storage/" + testFile); 37 databaseWorker.postMessage("runTest"); 38 } 39 -
trunk/LayoutTests/fast/workers/storage/resources/database-worker.js
r59540 r60387 28 28 29 29 var DB_TEST_SUFFIX = "_worker"; 30 31 function openDatabaseWithSuffix(name, version, description, size, callback) 32 { 33 if (arguments.length > 4) { 34 return openDatabase(name + DB_TEST_SUFFIX, version, description, size, callback); 35 } else { 36 return openDatabase(name + DB_TEST_SUFFIX, version, description, size); 37 } 38 } 39 -
trunk/LayoutTests/storage/change-version-handle-reuse.html
r59540 r60387 1 1 <html> 2 2 <head> 3 <script src="resources/database-common.js"></script> 3 4 <script src="change-version-handle-reuse.js"></script> 4 <script>5 6 var DB_TEST_SUFFIX = "_dom";7 8 function log(message)9 {10 document.getElementById("console").innerText += message + "\n";11 }12 13 function setupAndRunTest()14 {15 if (window.layoutTestController) {16 layoutTestController.waitUntilDone();17 layoutTestController.dumpAsText();18 }19 20 document.getElementById("console").innerText = "";21 22 runTest();23 }24 </script>25 5 </head> 26 6 <body onload="setupAndRunTest()"> -
trunk/LayoutTests/storage/change-version-handle-reuse.js
r59540 r60387 10 10 { 11 11 try { 12 db = openDatabase ("ChangeVersion" + DB_TEST_SUFFIX, "", "Test that changing a database version doesn't kill our handle to it", 1);12 db = openDatabaseWithSuffix("ChangeVersion", "", "Test that changing a database version doesn't kill our handle to it", 1); 13 13 var version = db.version; 14 14 var newVersion = version ? (parseInt(version) + 1).toString() : "1"; -
trunk/LayoutTests/storage/execute-sql-args.html
r59540 r60387 1 1 <html> 2 3 2 <head> 3 <script src="resources/database-common.js"></script> 4 4 <script src="execute-sql-args.js"></script> 5 <script>6 7 var DB_TEST_SUFFIX = "_dom";8 9 function log(message)10 {11 document.getElementById("console").innerText += message + "\n";12 }13 14 function setupAndRunTest()15 {16 if (window.layoutTestController) {17 layoutTestController.dumpAsText();18 layoutTestController.waitUntilDone();19 }20 runTest();21 }22 23 </script>24 5 </head> 25 6 26 7 <body onload="setupAndRunTest()"> 27 <pre id="console"></pre> 8 <pre id="console"> 9 FAILURE: test didn't run. 10 </pre> 28 11 </body> 29 12 -
trunk/LayoutTests/storage/execute-sql-args.js
r59540 r60387 82 82 { 83 83 84 var db = openDatabase ("ExecuteSQLArgsTest" + DB_TEST_SUFFIX, "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1);84 var db = openDatabaseWithSuffix("ExecuteSQLArgsTest", "1.0", "Test of handling of the arguments to SQLTransaction.executeSql", 1); 85 85 db.transaction(runTransactionTests); 86 86 } -
trunk/LayoutTests/storage/hash-change-with-xhr-expected.txt
r44468 r60387 2 2 Db is warmed up 3 3 Test Complete, SUCCESS 4 -
trunk/LayoutTests/storage/hash-change-with-xhr.html
r50969 r60387 2 2 <head> 3 3 <title>Hash Change with an Open XHR should not stop database transactions</title> 4 5 <script type="text/javascript"> 6 7 var DB_UPDATE_INTERVAL = 100; 8 var SEND_XHR_INTERVAL = 100; 9 var BACK_INTERVAL = 100; 10 var CREATE_HEALTH_TABLE = 'CREATE TABLE IF NOT EXISTS health (key VARCHAR(16) PRIMARY KEY);'; 11 var UPDATE_DATA = 'REPLACE INTO health VALUES("health-check-key");'; 12 13 var db = window.openDatabase('bug25710', '1.0', 'LayoutTest for bug 25710', 102400); 14 var backIterations; 15 var msgDiv; 16 var xhrFctIntervalId; 17 var backFctIntervalId; 18 var successCheckIntervalId; 19 var dbFctIntervalId; 20 var successes; 21 var databaseUpdates; 22 var stoppedIntervals; 23 24 function log(msg) 25 { 26 var newMsg = document.createElement('div'); 27 newMsg.innerText = msg; 28 msgDiv.appendChild(newMsg); 29 } 30 31 function stopIntervals() 32 { 33 stoppedIntervals = true; 34 window.clearInterval(dbFctIntervalId); 35 window.clearInterval(xhrFctIntervalId); 36 window.clearInterval(backFctIntervalId); 37 } 38 39 function stopTest(message) 40 { 41 if (!stoppedIntervals) 42 stopIntervals(); 43 44 log(message); 45 46 if (window.layoutTestController) 47 layoutTestController.notifyDone(); 48 } 49 50 function updateDatabase() 51 { 52 databaseUpdates++; 53 db.transaction(function(transaction) { 54 transaction.executeSql(UPDATE_DATA, [], function() {}, errorHandler); 55 }, errorHandler, function() { 56 successes++; 57 }); 58 } 59 60 function checkForSuccess() 61 { 62 if (successes == databaseUpdates) { 63 stopTest('Test Complete, SUCCESS'); 64 window.clearInterval(successCheckIntervalId); 65 } 66 } 67 68 function errorHandler(tx, error) 69 { 70 log('DB error, code: ' + error.code + ', msg: ' + error.message); 71 stopTest('Test Complete, FAILED'); 72 } 73 74 function sendXhr() 75 { 76 xhr = new XMLHttpRequest(); 77 xhr.open('GET', location.href, true); 78 xhr.send(''); 79 } 80 81 function invokeBack() 82 { 83 backIterations--; 84 if (backIterations) { 85 history.back(); 86 } else { 87 stopIntervals(); 88 // Allow a little time for all the database transactions to complete now we've stopped making them. 89 successCheckIntervalId = window.setInterval(checkForSuccess, 250); 90 // If we don't finish before this time, then we consider the test failed. 91 window.setTimeout(function() { stopTest('Timed out waiting for transactions to complete. FAILED'); }, 20000); 92 93 } 94 } 95 96 function runTest() 97 { 98 if (window.layoutTestController) { 99 layoutTestController.dumpAsText(); 100 layoutTestController.waitUntilDone(); 101 } 102 103 msgDiv = document.getElementById('msgs'); 104 105 msgDiv.innerHTML = ''; 106 backIterations = 10; 107 consecutiveFailures = 0; 108 successes = 0; 109 databaseUpdates = 0; 110 stoppedIntervals = false; 111 112 // Create some hashes so we can call history.back(). 113 log('Changing the hash to create history entries.'); 114 for (var i = 0; i < backIterations; i++) { 115 location.hash = i; 116 } 117 118 // Init the database. 119 db.transaction(function(transaction) { 120 transaction.executeSql(CREATE_HEALTH_TABLE, [], function() {}, errorHandler); 121 }, errorHandler, function() { 122 // Give a little for the database to 'warm up' before making xhr requests 123 // and calling history.back(). 124 window.setTimeout(function() { 125 log('Db is warmed up'); 126 127 // NOTE: If we don't make any xhr requests, then the test 128 // successfully passes (comment this line out). 129 xhrFctIntervalId = window.setInterval(sendXhr, SEND_XHR_INTERVAL); 130 backFctIntervalId = window.setInterval(invokeBack, BACK_INTERVAL); 131 dbFctIntervalId = window.setInterval(updateDatabase, DB_UPDATE_INTERVAL); 132 }, 500); 133 }); 134 } 135 </script> 4 <script src="resources/database-common.js"></script> 5 <script src="hash-change-with-xhr.js"></script> 136 6 </head> 137 <body onload="runTest()"> 138 <div id="msgs"></div> 7 <body onload="setupAndRunTest()"> 8 <pre id="console"> 9 FAILURE: test didn't run. 10 </pre> 139 11 </body> 140 12 </html> -
trunk/LayoutTests/storage/hash-change-with-xhr.js
r60386 r60387 1 <html>2 <head>3 <title>Hash Change with an Open XHR should not stop database transactions</title>4 5 <script type="text/javascript">6 7 1 var DB_UPDATE_INTERVAL = 100; 8 2 var SEND_XHR_INTERVAL = 100; … … 11 5 var UPDATE_DATA = 'REPLACE INTO health VALUES("health-check-key");'; 12 6 13 var db = window.openDatabase('bug25710', '1.0', 'LayoutTest for bug 25710', 102400);7 var db = openDatabaseWithSuffix('bug25710', '1.0', 'LayoutTest for bug 25710', 102400); 14 8 var backIterations; 15 var msgDiv;16 9 var xhrFctIntervalId; 17 10 var backFctIntervalId; … … 22 15 var stoppedIntervals; 23 16 24 function log(msg)25 {26 var newMsg = document.createElement('div');27 newMsg.innerText = msg;28 msgDiv.appendChild(newMsg);29 }30 31 17 function stopIntervals() 32 18 { 33 19 stoppedIntervals = true; 34 window.clearInterval(dbFctIntervalId);35 window.clearInterval(xhrFctIntervalId);36 window.clearInterval(backFctIntervalId);20 clearInterval(dbFctIntervalId); 21 clearInterval(xhrFctIntervalId); 22 clearInterval(backFctIntervalId); 37 23 } 38 24 … … 62 48 if (successes == databaseUpdates) { 63 49 stopTest('Test Complete, SUCCESS'); 64 window.clearInterval(successCheckIntervalId);50 clearInterval(successCheckIntervalId); 65 51 } 66 52 } … … 87 73 stopIntervals(); 88 74 // Allow a little time for all the database transactions to complete now we've stopped making them. 89 successCheckIntervalId = window.setInterval(checkForSuccess, 250);75 successCheckIntervalId = setInterval(checkForSuccess, 250); 90 76 // If we don't finish before this time, then we consider the test failed. 91 window.setTimeout(function() { stopTest('Timed out waiting for transactions to complete. FAILED'); }, 20000);77 setTimeout(function() { stopTest('Timed out waiting for transactions to complete. FAILED'); }, 20000); 92 78 93 79 } … … 96 82 function runTest() 97 83 { 98 if (window.layoutTestController) {99 layoutTestController.dumpAsText();100 layoutTestController.waitUntilDone();101 }102 103 msgDiv = document.getElementById('msgs');104 105 msgDiv.innerHTML = '';106 84 backIterations = 10; 107 85 consecutiveFailures = 0; … … 113 91 log('Changing the hash to create history entries.'); 114 92 for (var i = 0; i < backIterations; i++) { 115 location.hash = i;93 setLocationHash(i); 116 94 } 117 95 … … 122 100 // Give a little for the database to 'warm up' before making xhr requests 123 101 // and calling history.back(). 124 window.setTimeout(function() {102 setTimeout(function() { 125 103 log('Db is warmed up'); 126 104 127 105 // NOTE: If we don't make any xhr requests, then the test 128 106 // successfully passes (comment this line out). 129 xhrFctIntervalId = window.setInterval(sendXhr, SEND_XHR_INTERVAL);130 backFctIntervalId = window.setInterval(invokeBack, BACK_INTERVAL);131 dbFctIntervalId = window.setInterval(updateDatabase, DB_UPDATE_INTERVAL);107 xhrFctIntervalId = setInterval(sendXhr, SEND_XHR_INTERVAL); 108 backFctIntervalId = setInterval(invokeBack, BACK_INTERVAL); 109 dbFctIntervalId = setInterval(updateDatabase, DB_UPDATE_INTERVAL); 132 110 }, 500); 133 111 }); 134 112 } 135 </script>136 </head>137 <body onload="runTest()">138 <div id="msgs"></div>139 </body>140 </html> -
trunk/LayoutTests/storage/multiple-databases-garbage-collection.html
r30811 r60387 1 1 <html> 2 2 <head> 3 <script> 4 5 function log(message) 6 { 7 document.body.innerHTML += message + "<br>"; 8 } 9 10 function GC() 11 { 12 // Force GC. 13 if (window.GCController) 14 GCController.collect(); 15 else { 16 for (var i = 0; i < 10000; ++i) { 17 ({ }); 18 } 19 } 20 } 21 22 // Variable for the database that will never be forgotten 23 var persistentDB = 0; 24 // Variable for the forgotten database 25 var forgottenDB = 0; 26 27 var completed = 0; 28 function checkCompletion() 29 { 30 if (++completed == 2 && window.layoutTestController) 31 layoutTestController.notifyDone(); 32 } 33 34 function runTest() 35 { 36 if (window.layoutTestController) { 37 layoutTestController.dumpAsText(); 38 layoutTestController.waitUntilDone(); 39 } 40 41 persistentDB = openDatabase("MultipleDatabasesTest1", "1.0", "Test one out of a set of databases being destroyed (1)", 32768); 42 forgottenDB = openDatabase("MultipleDatabasesTest2", "1.0", "Test one out of a set of databases being destroyed (2)", 32768); 43 44 persistentDB.transaction(function(tx) { 45 tx.executeSql("CREATE TABLE IF NOT EXISTS DataTest (randomData)", [], function(tx, result) { 46 for (var i = 0; i < 25; ++i) 47 tx.executeSql("INSERT INTO DataTest (randomData) VALUES (1)", []); 48 }); 49 }, function(err) { 50 log("Persistent Database Transaction Errored - " + err); 51 checkCompletion(); 52 }, function() { 53 log("Persistent Database Transaction Complete"); 54 checkCompletion(); 55 }); 56 57 forgottenDB.transaction(function(tx) { 58 tx.executeSql("CREATE TABLE IF NOT EXISTS EmptyTable (unimportantData)", []); 59 }, function(err) { 60 log("Forgotten Database Transaction Errored - " + err); 61 forgottenDB = 0; 62 GC(); 63 checkCompletion(); 64 }, function() { 65 log("Forgotten Database Transaction Complete"); 66 forgottenDB = 0; 67 GC(); 68 checkCompletion(); 69 }); 70 } 71 72 </script> 73 <body onload="runTest();"> 3 <script src="resources/database-common.js"></script> 4 <script src="multiple-databases-garbage-collection.js"></script> 5 <body onload="setupAndRunTest();"> 74 6 This test opens two databases, queues up a series of operations on both, then "forgets" about one of them. 75 7 After forcing GC, resources associated with that database should be freed gracefully.<br> 8 <pre id="console"> 9 FAILURE: test didn't run. 10 </pre> 76 11 </body> 77 12 </html> -
trunk/LayoutTests/storage/multiple-databases-garbage-collection.js
r60386 r60387 1 <html>2 <head>3 <script>4 5 function log(message)6 {7 document.body.innerHTML += message + "<br>";8 }9 10 1 function GC() 11 2 { … … 34 25 function runTest() 35 26 { 36 if (window.layoutTestController) { 37 layoutTestController.dumpAsText(); 38 layoutTestController.waitUntilDone(); 39 } 40 41 persistentDB = openDatabase("MultipleDatabasesTest1", "1.0", "Test one out of a set of databases being destroyed (1)", 32768); 42 forgottenDB = openDatabase("MultipleDatabasesTest2", "1.0", "Test one out of a set of databases being destroyed (2)", 32768); 27 persistentDB = openDatabaseWithSuffix("MultipleDatabasesTest1", "1.0", "Test one out of a set of databases being destroyed (1)", 32768); 28 forgottenDB = openDatabaseWithSuffix("MultipleDatabasesTest2", "1.0", "Test one out of a set of databases being destroyed (2)", 32768); 43 29 44 30 persistentDB.transaction(function(tx) { … … 69 55 }); 70 56 } 71 72 </script>73 <body onload="runTest();">74 This test opens two databases, queues up a series of operations on both, then "forgets" about one of them.75 After forcing GC, resources associated with that database should be freed gracefully.<br>76 </body>77 </html> -
trunk/LayoutTests/storage/multiple-transactions-on-different-handles.html
r48653 r60387 1 1 <html> 2 2 <head> 3 <script> 4 5 function log(message) 6 { 7 document.body.innerHTML += message + "<br>"; 8 } 9 10 var complete = 0; 11 12 function checkCompletion() 13 { 14 // The test should end after two transactions 15 if (++complete == 2 && window.layoutTestController) 16 layoutTestController.notifyDone(); 17 } 18 19 // Opens the database used in this test case 20 function openTestDatabase() 21 { 22 return openDatabase("MultipleTransactionsOnDifferentHandlesTest", 23 "1.0", 24 "Test to make sure that queueing multiple transactions on different DB handles does not result in a deadlock.", 25 32768); 26 } 27 28 function statementSuccessCallback(dbName, statementType) 29 { 30 log(dbName + " " + statementType + " statement succeeded"); 31 } 32 33 function statementErrorCallback(dbName, statementType, error) 34 { 35 log(dbName + " " + statementType + " statement failed: " + error.message); 36 } 37 38 // Runs a transaction on the given database 39 function runTransaction(db, dbName, val) 40 { 41 db.transaction(function(tx) { 42 // Execute a read-only statement 43 tx.executeSql("SELECT COUNT(*) FROM Test;", [], 44 function(result) { statementSuccessCallback(dbName, "read"); }, 45 function(tx, error) { statementErrorCallback(dbName, "read", error); }); 46 47 // Execute a write statement to make sure SQLite tries to acquire an exclusive lock on the DB file 48 tx.executeSql("INSERT INTO Test VALUES (?);", [val], 49 function(result) { statementSuccessCallback(dbName, "write"); }, 50 function(tx, error) { statementErrorCallback(dbName, "write", error); }); 51 }, function(error) { 52 // Transaction failure callback 53 log(dbName + " transaction failed: " + error.message); 54 checkCompletion(); 55 }, function() { 56 // Transaction success callback 57 log(dbName + " transaction succeeded"); 58 checkCompletion(); 59 }); 60 } 61 62 // We need to guarantee that the Test table exists before we run our test. 63 // Therefore, the test code is in the successCallback of the transaction that creates the table. 64 function runTest() { 65 if (window.layoutTestController) { 66 layoutTestController.dumpAsText(); 67 layoutTestController.waitUntilDone(); 68 } 69 70 try { 71 var db = openTestDatabase(); 72 db.transaction(function(tx) { 73 // Create the Test table if it does not exist 74 tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);", [], 75 function(result) {}, function(tx, error) {}); 76 }, function(error) { 77 log("Creating the Test table failed: " + error.message); 78 }, function() { 79 // The Test table was created successfully 80 var db1 = openTestDatabase(); 81 var db2 = openTestDatabase(); 82 if (db1 == db2) 83 log("failure: db1 == db2"); 84 else { 85 runTransaction(db1, "db1", 1); 86 runTransaction(db2, "db2", 2); 87 } 88 }); 89 } catch(err) {} 90 } 91 </script> 3 <script src="resources/database-common.js"></script> 4 <script src="multiple-transactions-on-different-handles.js"></script> 92 5 </head> 93 <body onload=" runTest();">6 <body onload="setupAndRunTest();"> 94 7 This is a test to see if queueing up multiple transactions on different handles to the same database results in a deadlock.<br> 8 <pre id="console"> 9 FAILURE: test didn't run. 10 </pre> 95 11 </body> 96 12 </html> -
trunk/LayoutTests/storage/multiple-transactions-on-different-handles.js
r60386 r60387 1 <html>2 <head>3 <script>4 5 function log(message)6 {7 document.body.innerHTML += message + "<br>";8 }9 10 1 var complete = 0; 11 2 … … 20 11 function openTestDatabase() 21 12 { 22 return openDatabase ("MultipleTransactionsOnDifferentHandlesTest",23 "1.0",24 "Test to make sure that queueing multiple transactions on different DB handles does not result in a deadlock.",25 32768);13 return openDatabaseWithSuffix("MultipleTransactionsOnDifferentHandlesTest", 14 "1.0", 15 "Test to make sure that queueing multiple transactions on different DB handles does not result in a deadlock.", 16 32768); 26 17 } 27 18 … … 63 54 // Therefore, the test code is in the successCallback of the transaction that creates the table. 64 55 function runTest() { 65 if (window.layoutTestController) {66 layoutTestController.dumpAsText();67 layoutTestController.waitUntilDone();68 }69 70 56 try { 71 57 var db = openTestDatabase(); … … 89 75 } catch(err) {} 90 76 } 91 </script> 92 </head> 93 <body onload="runTest();"> 94 This is a test to see if queueing up multiple transactions on different handles to the same database results in a deadlock.<br> 95 </body> 96 </html> 77 78 -
trunk/LayoutTests/storage/multiple-transactions.html
r30578 r60387 1 1 <html> 2 2 <head> 3 <script> 4 5 function log(message) 6 { 7 document.body.innerHTML += message + "<br>"; 8 } 9 10 var complete = 0; 11 12 function checkCompletion() 13 { 14 if (++complete == 2 && window.layoutTestController) 15 layoutTestController.notifyDone(); 16 } 17 18 function runTest() 19 { 20 if (window.layoutTestController) { 21 layoutTestController.dumpAsText(); 22 layoutTestController.waitUntilDone(); 23 } 24 25 var db = openDatabase("MultipleTransactionsTest", "1.0", "Test to make sure multiple transactions can be queued at once for an HTML5 database", 32768); 26 27 db.transaction(function(tx) { 28 log("Transaction 1 Started"); 29 }, function(err) { 30 log("Transaction 1 Errored - " + err); 31 checkCompletion(); 32 }, function() { 33 log("Transaction 1 Succeeded"); 34 checkCompletion(); 35 }); 36 37 db.transaction(function(tx) { 38 log("Transaction 2 Started"); 39 }, function(err) { 40 log("Transaction 2 Errored - " + err); 41 checkCompletion(); 42 }, function() { 43 log("Transaction 2 Succeeded"); 44 checkCompletion(); 45 }); 46 } 47 48 </script> 3 <script src="resources/database-common.js"></script> 4 <script src="multiple-transactions.js"></script> 49 5 <head> 50 <body onload=" runTest();">6 <body onload="setupAndRunTest();"> 51 7 This is a test to see if the database API allows multiple transactions to be queued on the same database at once:<br> 8 <pre id="console"> 9 FAILURE: test didn't run. 10 </pre> 52 11 </body> 53 12 </html> -
trunk/LayoutTests/storage/multiple-transactions.js
r60386 r60387 1 <html>2 <head>3 <script>4 5 function log(message)6 {7 document.body.innerHTML += message + "<br>";8 }9 10 1 var complete = 0; 11 2 … … 18 9 function runTest() 19 10 { 20 if (window.layoutTestController) { 21 layoutTestController.dumpAsText(); 22 layoutTestController.waitUntilDone(); 23 } 24 25 var db = openDatabase("MultipleTransactionsTest", "1.0", "Test to make sure multiple transactions can be queued at once for an HTML5 database", 32768); 11 var db = openDatabaseWithSuffix("MultipleTransactionsTest", "1.0", "Test to make sure multiple transactions can be queued at once for an HTML5 database", 32768); 26 12 27 13 db.transaction(function(tx) { … … 45 31 }); 46 32 } 47 48 </script>49 <head>50 <body onload="runTest();">51 This is a test to see if the database API allows multiple transactions to be queued on the same database at once:<br>52 </body>53 </html> -
trunk/LayoutTests/storage/open-database-while-transaction-in-progress.html
r53021 r60387 1 1 <html> 2 2 <head> 3 <script> 4 5 function log(message) 6 { 7 document.body.innerHTML += message + "<br>"; 8 } 9 10 var complete = 0; 11 12 function checkCompletion() 13 { 14 // The test should end after two transactions 15 if (++complete == 1 && window.layoutTestController) 16 layoutTestController.notifyDone(); 17 } 18 19 // Opens the database used in this test case 20 function openTestDatabase() 21 { 22 return openDatabase("OpenDatabaseWhileTransactionInProgressTest", 23 "1.0", 24 "Test to make sure that calling openDatabase() while a transaction is in progress on a different handle to the same database does not result in a deadlock.", 25 2100000); // 2MB + epsilon 26 } 27 28 // See https://bugs.webkit.org/show_bug.cgi?id=28207 29 // In order to trigger this bug, the transaction must acquire an exclusive 30 // lock on the DB file before trying to obtain a second handle to the same DB. 31 // The only way to force SQLite to obtain an exclusive lock is to change more 32 // than cache_size * page_size bytes in the database. The default value for 33 // cache_size is 2000 pages, and the default page_size is 1024 bytes. So the 34 // size of the blob must be at least 2MB. 35 function runTest() 36 { 37 if (window.layoutTestController) { 38 layoutTestController.dumpAsText(); 39 layoutTestController.waitUntilDone(); 40 } 41 42 try { 43 var db1 = openTestDatabase(); 44 db1.transaction(function(tx) { 45 // Create the Test table if it does not exist 46 tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo BLOB);"); 47 tx.executeSql("INSERT INTO Test VALUES (ZEROBLOB(2097152));", [], 48 function(result) { 49 var db2 = openTestDatabase(); 50 log("openDatabase() succeeded."); 51 }, 52 function(tx, error) { 53 log("Executing statement failed: " + error.message); 54 }); 55 56 // Clean up the DB to allow for repeated runs of this test 57 // without needing to increase the default allowed quota (5MB) 58 tx.executeSql("DELETE FROM Test;"); 59 }, function(error) { 60 log("Transaction failed: " + error.message); 61 }, function() { 62 checkCompletion(); 63 }); 64 } catch(err) {} 65 } 66 </script> 3 <script src="resources/database-common.js"></script> 4 <script src="open-database-while-transaction-in-progress.js"></script> 67 5 </head> 68 <body onload=" runTest();">6 <body onload="setupAndRunTest();"> 69 7 This is a test to see if opening a database while a transaction is running on a different handle to the same database results in a deadlock.<br> 8 <pre id="console"> 9 FAILURE: test didn't run. 10 </pre> 70 11 </body> 71 12 </html> -
trunk/LayoutTests/storage/read-and-write-transactions-dont-run-together.html
r48653 r60387 1 1 <html> 2 2 <head> 3 <script> 4 5 function log(message) 6 { 7 document.body.innerHTML += message + "<br>"; 8 } 9 10 function terminateTest() 11 { 12 if (window.layoutTestController) 13 layoutTestController.notifyDone(); 14 } 15 16 function openTestDatabase() 17 { 18 return openDatabase("ReadAndWriteTransactionsDontRunTogetherTest", 19 "1.0", 20 "Test to make sure that read and write transactions on different DB handles to the same DB don't run at the same time.", 21 32768); 22 } 23 24 var readTransactionsInProgress = 0; 25 var writeTransactionsInProgress = 0; 26 var totalTransactions = 0; 27 var finishedTransactions = 0; 28 29 function runTransaction(db, readOnly) 30 { 31 var transactionFunction = (readOnly ? db.readTransaction : db.transaction); 32 transactionFunction.call(db, function(tx) { 33 if (readOnly) { 34 if (writeTransactionsInProgress != 0) { 35 log("Read transaction starting while write transaction in progress."); 36 terminateTest(); 37 } 38 readTransactionsInProgress++; 39 } else { 40 if ((readTransactionsInProgress != 0) || (writeTransactionsInProgress != 0)) { 41 log("Write transaction starting while another transaction in progress."); 42 terminateTest(); 43 } 44 writeTransactionsInProgress++; 45 } 46 tx.executeSql("SELECT * FROM Test;"); 47 }, function(error) { 48 log((readOnly ? "Read" : "Write") + " transaction failed: " + error.message); 49 terminateTest(); 50 }, function() { 51 finishedTransactions++; 52 if (readOnly) 53 readTransactionsInProgress--; 54 else 55 writeTransactionsInProgress--; 56 log("Transaction successful."); 57 if ((finishedTransactions == totalTransactions) && (readTransactionsInProgress == 0) && (writeTransactionsInProgress == 0)) 58 terminateTest(); 59 }); 60 } 61 62 function runReadAndWriteTransactions(db1, db2, db3) 63 { 64 totalTransactions = 10; 65 finishedTransactions = 0; 66 runTransaction(db1, true); 67 runTransaction(db2, true); 68 runTransaction(db1, false); 69 runTransaction(db1, true); 70 runTransaction(db2, true); 71 runTransaction(db3, true); 72 runTransaction(db1, false); 73 runTransaction(db2, false); 74 runTransaction(db1, true); 75 runTransaction(db3, true); 76 } 77 78 function runTest() { 79 if (window.layoutTestController) { 80 layoutTestController.dumpAsText(); 81 layoutTestController.waitUntilDone(); 82 } 83 84 try { 85 var db1 = openTestDatabase(); 86 var db2 = openTestDatabase(); 87 var db3 = openTestDatabase(); 88 db1.transaction(function(tx) { 89 tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);"); 90 }, function(error) { 91 log("Cannot create the Test table: " + error.message); 92 terminateTest(); 93 }, function() { 94 runReadAndWriteTransactions(db1, db2, db3); 95 }); 96 } catch(err) {} 97 } 98 </script> 3 <script src="resources/database-common.js"></script> 4 <script src="read-and-write-transactions-dont-run-together.js"></script> 99 5 </head> 100 <body onload=" runTest();">6 <body onload="setupAndRunTest();"> 101 7 This test tests that read and write transactions on different handles to the same database don't run together.<br> 8 <pre id="console"> 9 FAILURE: test didn't run. 10 </pre> 102 11 </body> 103 12 </html> -
trunk/LayoutTests/storage/read-and-write-transactions-dont-run-together.js
r60386 r60387 1 <html>2 <head>3 <script>4 5 function log(message)6 {7 document.body.innerHTML += message + "<br>";8 }9 10 1 function terminateTest() 11 2 { … … 16 7 function openTestDatabase() 17 8 { 18 return openDatabase ("ReadAndWriteTransactionsDontRunTogetherTest",19 "1.0",20 "Test to make sure that read and write transactions on different DB handles to the same DB don't run at the same time.",21 32768);9 return openDatabaseWithSuffix("ReadAndWriteTransactionsDontRunTogetherTest", 10 "1.0", 11 "Test to make sure that read and write transactions on different DB handles to the same DB don't run at the same time.", 12 32768); 22 13 } 23 14 … … 77 68 78 69 function runTest() { 79 if (window.layoutTestController) { 80 layoutTestController.dumpAsText(); 81 layoutTestController.waitUntilDone(); 82 } 83 84 try { 85 var db1 = openTestDatabase(); 86 var db2 = openTestDatabase(); 87 var db3 = openTestDatabase(); 88 db1.transaction(function(tx) { 89 tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);"); 90 }, function(error) { 91 log("Cannot create the Test table: " + error.message); 92 terminateTest(); 93 }, function() { 94 runReadAndWriteTransactions(db1, db2, db3); 95 }); 96 } catch(err) {} 70 var db1 = openTestDatabase(); 71 var db2 = openTestDatabase(); 72 var db3 = openTestDatabase(); 73 db1.transaction(function(tx) { 74 tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);"); 75 }, function(error) { 76 log("Cannot create the Test table: " + error.message); 77 terminateTest(); 78 }, function() { 79 runReadAndWriteTransactions(db1, db2, db3); 80 }); 97 81 } 98 </script>99 </head>100 <body onload="runTest();">101 This test tests that read and write transactions on different handles to the same database don't run together.<br>102 </body>103 </html> -
trunk/LayoutTests/storage/test-authorizer.html
r48653 r60387 1 1 <html> 2 2 <head> 3 <script> 4 5 function log(message) 6 { 7 document.body.innerHTML += message + "<br>"; 8 } 9 10 function terminateTest() 11 { 12 if (window.layoutTestController) 13 layoutTestController.notifyDone(); 14 } 15 16 function logAndTerminateTest(message, error) 17 { 18 log(message + ": " + error.message); 19 terminateTest(); 20 } 21 22 function cleanup(db) 23 { 24 db.transaction(function(tx) { 25 tx.executeSql("DROP TABLE IF EXISTS Test;"); 26 tx.executeSql("DROP INDEX IF EXISTS TestIndex;"); 27 tx.executeSql("DROP VIEW IF EXISTS TestView;"); 28 tx.executeSql("DROP TRIGGER IF EXISTS TestTrigger;"); 29 }, function(error) { logAndTerminateTest("Cleanup failed", error); }); 30 } 31 32 function statementSuccessCallback(statementType) 33 { 34 log(statementType + " statement succeeded."); 35 } 36 37 function statementErrorCallback(statementType, error) 38 { 39 log(statementType + " statement failed: " + error.message); 40 return false; 41 } 42 43 function executeStatement(tx, statement, operation) 44 { 45 tx.executeSql(statement, [], 46 function(result) { statementSuccessCallback(operation); }, 47 function(tx, error) { return statementErrorCallback(operation, error); }); 48 } 49 50 function createTableCallback(tx) 51 { 52 executeStatement(tx, "CREATE TABLE Test (Foo int);", "SQLITE_CREATE_TABLE"); 53 } 54 55 function createStatementsCallback(tx) 56 { 57 executeStatement(tx, "CREATE INDEX TestIndex ON Test (Foo);", "SQLITE_CREATE_INDEX"); 58 59 // Even though the following query should trigger a SQLITE_CREATE_TEMP_INDEX operation 60 // (according to http://www.sqlite.org/tempfiles.html), it doesn't, and I'm not aware 61 // of any other way to trigger this operation. So we'll skip it for now. 62 //executeStatement(tx, "SELECT * FROM Test WHERE Foo IN (1, 2, 3);", "SQLITE_CREATE_TEMP_INDEX"); 63 64 executeStatement(tx, "CREATE TEMP TABLE TestTempTable (Foo int);", "SQLITE_CREATE_TEMP_TABLE"); 65 executeStatement(tx, "CREATE TEMP TRIGGER TestTempTrigger INSERT ON Test BEGIN SELECT COUNT(*) FROM Test; END;", "SQLITE_CREATE_TEMP_TRIGGER"); 66 executeStatement(tx, "CREATE TEMP VIEW TestTempView AS SELECT COUNT(*) FROM Test;", "SQLITE_CREATE_TEMP_VIEW"); 67 executeStatement(tx, "CREATE TRIGGER TestTrigger INSERT ON Test BEGIN SELECT COUNT(*) FROM Test; END;", "SQLITE_CREATE_TRIGGER"); 68 executeStatement(tx, "CREATE VIEW TestView AS SELECT COUNT(*) FROM Test;", "SQLITE_CREATE_VIEW"); 69 executeStatement(tx, "CREATE VIRTUAL TABLE TestVirtualTable USING MissingModule;", "SQLITE_CREATE_VTABLE"); 70 } 71 72 function otherStatementsCallback(tx) 73 { 74 executeStatement(tx, "SELECT COUNT(*) FROM Test;", "SQLITE_READ"); 75 executeStatement(tx, "SELECT COUNT(*) FROM Test;", "SQLITE_SELECT"); 76 executeStatement(tx, "DELETE FROM Test;", "SQLITE_DELETE"); 77 executeStatement(tx, "INSERT INTO Test VALUES (1);", "SQLITE_INSERT"); 78 executeStatement(tx, "UPDATE Test SET Foo = 2 WHERE Foo = 1;", "SQLITE_UPDATE"); 79 executeStatement(tx, "PRAGMA cache_size;", "SQLITE_PRAGMA"); 80 81 executeStatement(tx, "ALTER TABLE Test RENAME TO TestTable;", "SQLITE_ALTER_TABLE"); 82 // Rename the table back to its original name 83 executeStatement(tx, "ALTER TABLE TestTable RENAME To Test;", "SQLITE_ALTER_TABLE"); 84 85 executeStatement(tx, "BEGIN TRANSACTION;", "SQLITE_TRANSACTION"); 86 executeStatement(tx, "ATTACH main AS TestMain;", "SQLITE_ATTACH"); 87 executeStatement(tx, "DETACH TestMain;", "SQLITE_DETACH"); 88 executeStatement(tx, "REINDEX;", "SQLITE_REINDEX"); 89 executeStatement(tx, "ANALYZE;", "SQLITE_ANALYZE"); 90 91 // SQLITE_FUNCTION: allowed write mode 92 // There is no SQL/Javascript API to add user-defined functions to SQLite, 93 // so we cannot test this operation 94 } 95 96 function dropStatementsCallback(tx) 97 { 98 executeStatement(tx, "DROP INDEX TestIndex;", "SQLITE_DROP_INDEX"); 99 100 // SQLITE_DROP_TEMP_INDEX: allowed in write mode 101 // Not sure how to test this: temp indexes are automatically dropped when 102 // the database is closed, but HTML5 doesn't specify a closeDatabase() call. 103 104 executeStatement(tx, "DROP TABLE TestTempTable;", "SQLITE_DROP_TEMP_TABLE"); 105 executeStatement(tx, "DROP TRIGGER TestTempTrigger;", "SQLITE_DROP_TEMP_TRIGGER"); 106 executeStatement(tx, "DROP VIEW TestTempView;", "SQLITE_DROP_TEMP_VIEW"); 107 executeStatement(tx, "DROP TRIGGER TestTrigger;", "SQLITE_DROP_TRIGGER"); 108 executeStatement(tx, "DROP VIEW TestView;", "SQLITE_DROP_VIEW"); 109 110 // SQLITE_DROP_VTABLE: allowed in write mode 111 // Not sure how to test this: we cannot create a virtual table because we do not 112 // have SQL/Javascript APIs to register a module that implements a virtual table. 113 // Therefore, trying to drop a virtual table will always fail (no such table) 114 // before even getting to the authorizer. 115 116 executeStatement(tx, "DROP TABLE Test;", "SQLITE_DROP_TABLE"); 117 } 118 119 function testReadWriteMode(db) 120 { 121 db.transaction(function(tx) { 122 createTableCallback(tx); 123 createStatementsCallback(tx); 124 otherStatementsCallback(tx); 125 dropStatementsCallback(tx); 126 }, 127 function(error) { logAndTerminateTest("Write transaction failed", error); }, 128 function() { log("Write transaction succeeded."); }); 129 } 130 131 function testReadOnlyMode(db) 132 { 133 // Test the 'CREATE TABLE' operation; it should be disallowed 134 db.readTransaction(createTableCallback, 135 function(error) { logAndTerminateTest("Read 'CREATE TABLE' transaction failed", error); }); 136 137 // In order to test all other 'CREATE' operations, we must create the table first 138 db.transaction(createTableCallback, 139 function(error) { logAndTerminateTest("Write 'CREATE TABLE' transaction failed", error); }); 140 db.readTransaction(createStatementsCallback, 141 function(error) { logAndTerminateTest("Read 'CREATE' transaction failed", error); }); 142 143 // In order to test the 'DROP' and 'other' operations, we need to first create the respective entities 144 db.transaction(createStatementsCallback, 145 function(error) { logAndTerminateTest("Write 'CREATE' transaction failed", error); }); 146 db.readTransaction(otherStatementsCallback, 147 function(error) { logAndTerminateTest("Read 'other' transaction failed", error); }); 148 149 // Hack: insert an empty write transaction to guaratee that these transactions are executed sequentially 150 db.transaction(function(tx) { }); 151 db.readTransaction(dropStatementsCallback, 152 function(error) { logAndTerminateTest("Read 'DROP' transaction failed", error); }, 153 function() { log("Read transactions succeeded."); terminateTest(); }); 154 } 155 156 function runTest() 157 { 158 if (window.layoutTestController) { 159 layoutTestController.dumpAsText(); 160 layoutTestController.waitUntilDone(); 161 } 162 163 try { 164 var db = openDatabase("AuthorizerTest", "1.0", "Tests the database authorizer.", 32768); 165 cleanup(db); 166 testReadWriteMode(db); 167 testReadOnlyMode(db); 168 } catch(err) {} 169 } 170 </script> 3 <script src="resources/database-common.js"></script> 4 <script src="test-authorizer.js"></script> 171 5 </head> 172 <body onload=" runTest();">6 <body onload="setupAndRunTest();"> 173 7 This test tests the database authorizer.<br> 8 <pre id="console"> 9 FAILURE: test didn't run. 10 </pre> 174 11 </body> 175 12 </html> -
trunk/LayoutTests/storage/test-authorizer.js
r60386 r60387 1 <html>2 <head>3 <script>4 5 function log(message)6 {7 document.body.innerHTML += message + "<br>";8 }9 10 1 function terminateTest() 11 2 { … … 156 147 function runTest() 157 148 { 158 if (window.layoutTestController) { 159 layoutTestController.dumpAsText(); 160 layoutTestController.waitUntilDone(); 161 } 162 163 try { 164 var db = openDatabase("AuthorizerTest", "1.0", "Tests the database authorizer.", 32768); 165 cleanup(db); 166 testReadWriteMode(db); 167 testReadOnlyMode(db); 168 } catch(err) {} 149 var db = openDatabaseWithSuffix("AuthorizerTest", "1.0", "Tests the database authorizer.", 32768); 150 cleanup(db); 151 testReadWriteMode(db); 152 testReadOnlyMode(db); 169 153 } 170 </script>171 </head>172 <body onload="runTest();">173 This test tests the database authorizer.<br>174 </body>175 </html>
Note: See TracChangeset
for help on using the changeset viewer.