summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/read-transactions-running-concurrently.html
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/storage/read-transactions-running-concurrently.html')
-rw-r--r--LayoutTests/storage/read-transactions-running-concurrently.html67
1 files changed, 67 insertions, 0 deletions
diff --git a/LayoutTests/storage/read-transactions-running-concurrently.html b/LayoutTests/storage/read-transactions-running-concurrently.html
new file mode 100644
index 0000000..b2d862c
--- /dev/null
+++ b/LayoutTests/storage/read-transactions-running-concurrently.html
@@ -0,0 +1,67 @@
+<html>
+<head>
+<script>
+
+function log(message)
+{
+ document.body.innerHTML += message + "<br>";
+}
+
+function terminateTest()
+{
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function openTestDatabase()
+{
+ return openDatabase("ReadTransactionsRunningConcurrentlyTest",
+ "1.0",
+ "Test to make sure that multiple read transactions on different DB handles to the same DB run concurrently.",
+ 32768);
+}
+
+var readTransactionsInProgress = 0;
+
+function runReadTransaction(db)
+{
+ db.readTransaction(function(tx) {
+ readTransactionsInProgress++;
+ }, function(error) {
+ log("Read transaction failed: " + error.message);
+ terminateTest();
+ }, function() {
+ if (readTransactionsInProgress == 2)
+ log("Read transactions running concurrently.");
+ readTransactionsInProgress--;
+ if (readTransactionsInProgress == 0)
+ terminateTest();
+ });
+}
+
+function runTest() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ try {
+ var db1 = openTestDatabase();
+ var db2 = openTestDatabase();
+ db1.transaction(function(tx) {
+ tx.executeSql("CREATE TABLE IF NOT EXISTS Test (Foo int);");
+ }, function(error) {
+ log("Cannot create the Test table: " + error.message);
+ terminateTest();
+ }, function() {
+ runReadTransaction(db1);
+ runReadTransaction(db2);
+ });
+ } catch(err) { log(err); }
+}
+</script>
+</head>
+<body onload="runTest();">
+This test tests that two read-only transactions on different handles to the same database run concurrently.<br>
+</body>
+</html>