Home | History | Annotate | Download | only in ManualTests
      1 <!doctype html>
      2 <html>
      3 <head>
      4 
      5 <style>
      6 pre { padding: 5px; border: 1px solid black; }
      7 </style>
      8 
      9 <script>
     10 var db;
     11 
     12 try {
     13     if (window.openDatabase) {
     14         db = openDatabase("StressTest1", "1.0", "Database Stress Test", 200000);
     15         if (!db)
     16             alert("Failed to open the database on disk.  This is probably because the version was bad or there is not enough space left in this domain's quota");
     17     } else
     18         alert("Couldn't open the database.");
     19 } catch(err) { }
     20 
     21 var highestId = 0;
     22 var allData = new Array();
     23 
     24 function newData()
     25 {
     26     var id = ++highestId;
     27     allData.push(id);
     28     db.transaction(function (tx) 
     29     {
     30         tx.executeSql("INSERT INTO FillerData (id, filler) VALUES (?, randomblob(1024))", [id]);
     31     }); 
     32 }
     33 
     34 function testOpen()
     35 {
     36     for (var i = 0; i < 4; i++) {
     37         newData();
     38     }
     39 
     40     setTimeout("testClose();", 0);
     41 }
     42 
     43 function testClose()
     44 {    
     45     db.transaction(function(tx)
     46     {   
     47         for (var i = 0; i < allData.length; i++)
     48             tx.executeSql("DELETE FROM FillerData WHERE id = ?", [allData[i]]);
     49 
     50         allData = new Array();
     51     });
     52     setTimeout("testOpen();", 0);
     53 }
     54 
     55 function updateTransactionCount()
     56 {
     57     document.getElementById("transactionCount").innerHTML = "Current Transaction Count: " + highestId;
     58     setTimeout("updateTransactionCount();", 1000);
     59 }
     60 
     61 function loaded()
     62 {
     63     db.transaction(function(tx) {
     64         tx.executeSql("SELECT COUNT(*) FROM FillerData", [], function(result) { }, function(tx, error) {
     65             tx.executeSql("CREATE TABLE FillerData (id REAL UNIQUE, filler)", [], function(result) { 
     66             });
     67         });
     68     });
     69 
     70     setTimeout("testOpen();", 0);
     71     setTimeout("updateTransactionCount();", 1000);
     72 }
     73 
     74 addEventListener('load', loaded, false);
     75 </script>
     76 </head>
     77 
     78 <body>
     79 This test stresses the database threading code by constantly opening transactions to the test database at a fast rate.<br>
     80 See radar 5729446 for more details.<br>
     81 <pre id="transactionCount">Current Transaction Count: 0</pre>
     82 
     83 </body>
     84 </html>
     85