Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / websql / read-transactions-running-concurrently.html
blob2e2efe972312e31e09b62bb19c4d0085593feb90
1 <html>
2 <head>
3 <script>
5 function log(message)
7 document.body.innerHTML += message + "<br>";
10 function terminateTest()
12 if (window.testRunner)
13 testRunner.notifyDone();
16 function openTestDatabase()
18 return openDatabase("ReadTransactionsRunningConcurrentlyTest",
19 "1.0",
20 "Test to make sure that multiple read transactions on different DB handles to the same DB run concurrently.",
21 32768);
24 var readTransactionsInProgress = 0;
25 var done = false;
27 function runReadTransaction(db)
30 db.readTransaction(
31 function(tx) {
32 ++readTransactionsInProgress;
33 if (readTransactionsInProgress === 2) {
34 log("Read transactions running concurrently.");
35 done = true;
38 (function spin() {
39 if (done)
40 return;
41 tx.executeSql("SELECT ? AS zero", [0], spin,
42 errorHandler("execute failed"));
43 }());
45 errorHandler("Read transaction failed"),
46 function() {
47 readTransactionsInProgress--;
48 if (readTransactionsInProgress === 0)
49 terminateTest();
50 });
53 function errorHandler(message) {
54 return function(error) {
55 log(message + ": " + error.message);
56 terminateTest();
60 function runTest() {
61 if (window.testRunner) {
62 testRunner.clearAllDatabases();
63 testRunner.dumpAsText();
64 testRunner.waitUntilDone();
67 try {
68 var db1 = openTestDatabase();
69 var db2 = openTestDatabase();
70 db1.transaction(
71 function(tx) {
72 tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);");
74 errorHandler("Cannot create the Test table"),
75 function() {
76 runReadTransaction(db1);
77 runReadTransaction(db2);
78 });
79 } catch(err) { log(err); }
81 </script>
82 </head>
83 <body onload="runTest();">
84 This test tests that two read-only transactions on different handles to the same database run concurrently.<br>
85 </body>
86 </html>