Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / websql / read-and-write-transactions-dont-run-together.js
blobbeb1e89bbc7d6335c9060acebe3fa286459cb6b4
1 function terminateTest()
3 if (window.testRunner)
4 testRunner.notifyDone();
7 function openTestDatabase()
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);
15 var readTransactionsInProgress = 0;
16 var writeTransactionsInProgress = 0;
17 var totalTransactions = 0;
18 var finishedTransactions = 0;
20 function runTransaction(db, readOnly)
22 var transactionFunction = (readOnly ? db.readTransaction : db.transaction);
23 transactionFunction.call(db, function(tx) {
24 if (readOnly) {
25 if (writeTransactionsInProgress != 0) {
26 log("Read transaction starting while write transaction in progress.");
27 terminateTest();
29 readTransactionsInProgress++;
30 } else {
31 if ((readTransactionsInProgress != 0) || (writeTransactionsInProgress != 0)) {
32 log("Write transaction starting while another transaction in progress.");
33 terminateTest();
35 writeTransactionsInProgress++;
37 tx.executeSql("SELECT * FROM Test;");
38 }, function(error) {
39 log((readOnly ? "Read" : "Write") + " transaction failed: " + error.message);
40 terminateTest();
41 }, function() {
42 finishedTransactions++;
43 if (readOnly)
44 readTransactionsInProgress--;
45 else
46 writeTransactionsInProgress--;
47 log("Transaction successful.");
48 if ((finishedTransactions == totalTransactions) && (readTransactionsInProgress == 0) && (writeTransactionsInProgress == 0))
49 terminateTest();
50 });
53 function runReadAndWriteTransactions(db1, db2, db3)
55 totalTransactions = 10;
56 finishedTransactions = 0;
57 runTransaction(db1, true);
58 runTransaction(db2, true);
59 runTransaction(db1, false);
60 runTransaction(db1, true);
61 runTransaction(db2, true);
62 runTransaction(db3, true);
63 runTransaction(db1, false);
64 runTransaction(db2, false);
65 runTransaction(db1, true);
66 runTransaction(db3, true);
69 function runTest() {
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 });